Hi,
-- So maybe I'm getting everything wrong, but I'm a little confused with routing.
Let's say I want to separate the consumers dealing with messages coming from my domain root:
http://domain.com/
and my `/import/` route:
http://domain.com/import/
I have my routing as so:
fb_routing = [
route("websocket.connect", consumers.connect_face),
route("websocket.receive", consumers.get_face),
route("websocket.disconnect", consumers.disconnect_face)
]
channel_routing = [
include(fb_routing, path=r'^/import/'),
route('websocket.connect', consumers.ws_connect),
route('websocket.disconnect', consumers.ws_disconnect),
route('websocket.receive', consumers.ws_receive),
]I'm also separating the Javascript files for initiating the Reconnecting Websockets, in each file I set the path accordingly:
root.js:
var ws_scheme = window.location.protocol == "http:" ? "ws" : "wss";
var ws_path = ws_scheme + '://' + window.location.host + "/";
console.log("Connecting to " + ws_path);
var mysocket = new ReconnectingWebSocket(ws_path);
and import.js:
var ws_scheme = window.location.protocol == "http:" ? "ws" : "wss";
var ws_path = ws_scheme + '://' + window.location.host + "/import/";
console.log("Connecting to " + ws_path);
var mysocket = new ReconnectingWebSocket(ws_path);How can I prevent my receive consumer for import (see: consumers.get_face in routing) from getting or even listening to messages on the root (whose receive consumer is consumers.ws_receive), and vice versa?
Right when I open the console, both messages are sent to both consumers. I guess I can parse the path from the messages, but that seems very laborious!
I'm referencing Andrew's answer to one Github issue here:
Ah, well that's because you don't have a path key in your message - the routing isn't magical, it just goes off of the contents of the message.websocket.connectandwebsocket.receivemessages include apathkey so they can be routed, whereas yours just has amessagekey.
Given you have made a separate channel especially for this, there's no need for the path routing unless you really want to distinguish it, in which case you should ensure a path is added to the message when it's sent onto the channel.
The confusing sentence to me here is "Given you have made a separate channel especially for this, there's no need for the path routing". Does that imply that there is a way for me to avoid customizing the Group name every time?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ff59b765-c428-4313-8a21-f9bf897f79a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment