1
我希望你沒事:是否可以在連接中分配django頻道組?
我的問題是我是否能對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)})
謝謝拉胡爾 – NEFEGAGO