【发布时间】:2018-04-02 17:46:53
【问题描述】:
希望你没事:
我的问题是我是否可以从客户端连接到特定组的 Web 套接字, 我目前正在按如下方式连接客户:
//connecting client with js
var ws_scheme = window. location. protocol == "https:"? "wss":"ws";
//var ws_path = ws_scheme +': //' + window. location. host + "/sync/";
var ws_path = ws_scheme + ": //localhost: 8001";
console. log ("Connecting to " + ws_path);
var socket = new ReconnectingWebSocket (ws_path);
好的,就是这样, 问题是我希望每个客户端都连接到一个组 之前创建的例子:
def ws_connect (message):
for x in users:
Group (x). add (message. reply_channel)
然后将消息发送到相应的组
Group ("group1"). send ({' text': json. dumps (msg)})
Group ("group2"). send ({' text': json. dumps (msg)})
【问题讨论】:
标签: python django websocket channels