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:
and my `/import/` route:
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!
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.connect and websocket.receive messages include a path key so they can be routed, whereas yours just has a message key.
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?