mirror of
https://github.com/django/daphne.git
synced 2024-11-22 16:06:34 +03:00
Change to new style of single-reader channel
This commit is contained in:
parent
25626fa3bf
commit
e7b323893f
|
@ -45,7 +45,7 @@ class WebRequest(http.Request):
|
||||||
# Easy factory link
|
# Easy factory link
|
||||||
self.factory = self.channel.factory
|
self.factory = self.channel.factory
|
||||||
# Make a name for our reply channel
|
# Make a name for our reply channel
|
||||||
self.reply_channel = self.factory.channel_layer.new_channel("!http.response.?")
|
self.reply_channel = self.factory.channel_layer.new_channel("http.response!")
|
||||||
# Tell factory we're that channel's client
|
# Tell factory we're that channel's client
|
||||||
self.last_keepalive = time.time()
|
self.last_keepalive = time.time()
|
||||||
self.factory.reply_protocols[self.reply_channel] = self
|
self.factory.reply_protocols[self.reply_channel] = self
|
||||||
|
@ -235,9 +235,9 @@ class HTTPFactory(http.HTTPFactory):
|
||||||
return self.reply_protocols.keys()
|
return self.reply_protocols.keys()
|
||||||
|
|
||||||
def dispatch_reply(self, channel, message):
|
def dispatch_reply(self, channel, message):
|
||||||
if channel.startswith("!http") and isinstance(self.reply_protocols[channel], WebRequest):
|
if channel.startswith("http") and isinstance(self.reply_protocols[channel], WebRequest):
|
||||||
self.reply_protocols[channel].serverResponse(message)
|
self.reply_protocols[channel].serverResponse(message)
|
||||||
elif channel.startswith("!websocket") and isinstance(self.reply_protocols[channel], WebSocketProtocol):
|
elif channel.startswith("websocket") and isinstance(self.reply_protocols[channel], WebSocketProtocol):
|
||||||
if message.get("bytes", None):
|
if message.get("bytes", None):
|
||||||
self.reply_protocols[channel].serverSend(message["bytes"], True)
|
self.reply_protocols[channel].serverSend(message["bytes"], True)
|
||||||
if message.get("text", None):
|
if message.get("text", None):
|
||||||
|
|
|
@ -35,7 +35,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
# TODO: get autobahn to provide it raw
|
# TODO: get autobahn to provide it raw
|
||||||
query_string = urlencode(request.params, doseq=True).encode("ascii")
|
query_string = urlencode(request.params, doseq=True).encode("ascii")
|
||||||
# Make sending channel
|
# Make sending channel
|
||||||
self.reply_channel = self.channel_layer.new_channel("!websocket.send.?")
|
self.reply_channel = self.channel_layer.new_channel("websocket.send!")
|
||||||
# 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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user