| 272 | yield from super().handle_event(event) |
| 273 | |
| 274 | def _handle_event(self, event: mevents.Event): |
| 275 | self.events.append(event) |
| 276 | |
| 277 | # We receive new data. Let's find out if we can determine the next layer now? |
| 278 | if self._ask_on_start and isinstance(event, events.Start): |
| 279 | yield from self._ask() |
| 280 | elif ( |
| 281 | isinstance(event, mevents.ConnectionClosed) |
| 282 | and event.connection == self.context.client |
| 283 | ): |
| 284 | # If we have not determined the next protocol yet and the client already closes the connection, |
| 285 | # we abort everything. |
| 286 | yield commands.CloseConnection(self.context.client) |
| 287 | elif isinstance(event, mevents.DataReceived): |
| 288 | # For now, we only ask if we have received new data to reduce hook noise. |
| 289 | yield from self._ask() |
| 290 | |
| 291 | def _ask(self): |
| 292 | """ |