Skip to content

Commit

Permalink
Simplify message on wsproto
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Dec 3, 2023
1 parent 0c2ac87 commit 97ec25d
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions uvicorn/protocols/websockets/wsproto_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
WebSocketAcceptEvent,
WebSocketCloseEvent,
WebSocketEvent,
WebSocketReceiveEvent,
WebSocketScope,
WebSocketSendEvent,
)
Expand Down Expand Up @@ -181,11 +180,7 @@ def handle_connect(self, event: events.Request) -> None:
def handle_text(self, event: events.TextMessage) -> None:
self.text += event.data
if event.message_finished:
msg: "WebSocketReceiveEvent" = {
"type": "websocket.receive",
"text": self.text,
}
self.queue.put_nowait(msg)
self.queue.put_nowait({"type": "websocket.receive", "text": self.text})
self.text = ""
if not self.read_paused:
self.read_paused = True
Expand All @@ -195,11 +190,7 @@ def handle_bytes(self, event: events.BytesMessage) -> None:
self.bytes += event.data
# todo: we may want to guard the size of self.bytes and self.text
if event.message_finished:
msg: WebSocketReceiveEvent = {
"type": "websocket.receive",
"bytes": self.bytes,
}
self.queue.put_nowait(msg)
self.queue.put_nowait({"type": "websocket.receive", "bytes": self.bytes})
self.bytes = b""
if not self.read_paused:
self.read_paused = True
Expand Down

0 comments on commit 97ec25d

Please sign in to comment.