Update daphne to new asgi spec

This commit is contained in:
Andrew Godwin 2016-03-20 12:29:04 -03:00
parent 89ebad14f9
commit 25626fa3bf

View File

@ -39,8 +39,9 @@ class WebSocketProtocol(WebSocketServerProtocol):
# Tell main factory about it
self.main_factory.reply_protocols[self.reply_channel] = self
# Make initial request info dict from request (we only have it here)
self.path = request.path.encode("ascii")
self.request_info = {
"path": request.path.encode("ascii"),
"path": self.path,
"headers": clean_headers,
"query_string": query_string,
"client": [self.transport.getPeer().host, self.transport.getPeer().port],
@ -69,12 +70,14 @@ class WebSocketProtocol(WebSocketServerProtocol):
if isBinary:
self.channel_layer.send("websocket.receive", {
"reply_channel": self.reply_channel,
"path": self.path,
"order": self.packets_received,
"bytes": payload,
})
else:
self.channel_layer.send("websocket.receive", {
"reply_channel": self.reply_channel,
"path": self.path,
"order": self.packets_received,
"text": payload.decode("utf8"),
})
@ -101,6 +104,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
del self.factory.reply_protocols[self.reply_channel]
self.channel_layer.send("websocket.disconnect", {
"reply_channel": self.reply_channel,
"path": self.path,
"order": self.packets_received + 1,
})
self.factory.log_action("websocket", "disconnected", {