mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +03:00
Update daphne to new asgi spec
This commit is contained in:
parent
89ebad14f9
commit
25626fa3bf
|
@ -39,8 +39,9 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
# Tell main factory about it
|
# Tell main factory about it
|
||||||
self.main_factory.reply_protocols[self.reply_channel] = self
|
self.main_factory.reply_protocols[self.reply_channel] = self
|
||||||
# Make initial request info dict from request (we only have it here)
|
# Make initial request info dict from request (we only have it here)
|
||||||
|
self.path = request.path.encode("ascii")
|
||||||
self.request_info = {
|
self.request_info = {
|
||||||
"path": request.path.encode("ascii"),
|
"path": self.path,
|
||||||
"headers": clean_headers,
|
"headers": clean_headers,
|
||||||
"query_string": query_string,
|
"query_string": query_string,
|
||||||
"client": [self.transport.getPeer().host, self.transport.getPeer().port],
|
"client": [self.transport.getPeer().host, self.transport.getPeer().port],
|
||||||
|
@ -69,12 +70,14 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
if isBinary:
|
if isBinary:
|
||||||
self.channel_layer.send("websocket.receive", {
|
self.channel_layer.send("websocket.receive", {
|
||||||
"reply_channel": self.reply_channel,
|
"reply_channel": self.reply_channel,
|
||||||
|
"path": self.path,
|
||||||
"order": self.packets_received,
|
"order": self.packets_received,
|
||||||
"bytes": payload,
|
"bytes": payload,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
self.channel_layer.send("websocket.receive", {
|
self.channel_layer.send("websocket.receive", {
|
||||||
"reply_channel": self.reply_channel,
|
"reply_channel": self.reply_channel,
|
||||||
|
"path": self.path,
|
||||||
"order": self.packets_received,
|
"order": self.packets_received,
|
||||||
"text": payload.decode("utf8"),
|
"text": payload.decode("utf8"),
|
||||||
})
|
})
|
||||||
|
@ -101,6 +104,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
del self.factory.reply_protocols[self.reply_channel]
|
del self.factory.reply_protocols[self.reply_channel]
|
||||||
self.channel_layer.send("websocket.disconnect", {
|
self.channel_layer.send("websocket.disconnect", {
|
||||||
"reply_channel": self.reply_channel,
|
"reply_channel": self.reply_channel,
|
||||||
|
"path": self.path,
|
||||||
"order": self.packets_received + 1,
|
"order": self.packets_received + 1,
|
||||||
})
|
})
|
||||||
self.factory.log_action("websocket", "disconnected", {
|
self.factory.log_action("websocket", "disconnected", {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user