On Thursday, March 17, 2016 at 5:42:05 PM UTC+1, Jacob Kaplan-Moss wrote:
>
> Channels routes all WebSocket connections to a single set of consumers 
> (the `websocket.*` consumers). This means that if you want multiple 
> WebSocket URLs in a single app you need to manually parse the path. And, to 
> make things more complicated, you only get the WebSocket path passed in the 
> connection message, so you have to also use a channel session to keep track.
>

Yes, this seems like a major pain point, especially since the routing does 
not scale if you add another app, ie you need to add a wrapper which then 
dispatches to the individual connect routines. In a best case scenario I'd 
just have to add another router in the settings and get everything 
dispatched to the correct handlers (in that sense, the ROUTING setting 
should allow for multiple entries). Basically I think there needs to be a 
way to scope websocket.* to a single session(type) [And we should have this 
from the start]. Maybe something along the lines of:
```
channel_routing = {
  '^chat/(?P<room>\w+)': {
    'websocket.connect': …,
    'websocket.receive': …,
  },
  '^notifies/…': {
    'websocket.connect': …,
    'websocket.receive': …,
  },
  '^.*': {
    'http.request': my_handler
  }
}
```

So in essence: If the URL starts with "chat", the handlers for this "scope" 
should get called with room as argument (the data is already there, ) -- 
just like normal views. Same goes for notifications… I realize that this 
definition seems overly complicated, but this is the feature set I'd expect 
personally. Theoretically, the frontend server should have this information 
over the whole (websocket)session anyways and there shouldn't be any need 
for channel_session at all (That said, channel_session does not work with 
signed cookies ;)).

Cheers,
Florian

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5f957bbb-f025-4d85-97c5-a9a62cf86296%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to