(self, event: events.TextMessage | events.BytesMessage)
| 225 | self.tasks.add(task) |
| 226 | |
| 227 | def handle_message(self, event: events.TextMessage | events.BytesMessage) -> None: |
| 228 | try: |
| 229 | self.buffer.extend(event) |
| 230 | except FrameTooLargeError: |
| 231 | self.close_sent = True |
| 232 | reason = f"Message exceeds the maximum size ({self.config.ws_max_size} bytes)" |
| 233 | self.queue.put_nowait({"type": "websocket.disconnect", "code": 1009, "reason": reason}) |
| 234 | if not self.transport.is_closing(): |
| 235 | self.transport.write(self.conn.send(wsproto.events.CloseConnection(code=1009, reason=reason))) |
| 236 | self.transport.close() |
| 237 | return |
| 238 | if event.message_finished: |
| 239 | self.queue.put_nowait(self.buffer.to_message()) |
| 240 | self.buffer.clear() |
| 241 | if not self.read_paused: |
| 242 | self.read_paused = True |
| 243 | self.transport.pause_reading() |
| 244 | |
| 245 | def handle_close(self, event: events.CloseConnection) -> None: |
| 246 | if self.conn.state == ConnectionState.REMOTE_CLOSING: |
no test coverage detected