实现的功能是django后台数据更新之后,例如说一个群组人员增加,不刷新页面实现推送消息的功能,但是不是很懂dwebsocket的机制:
给的实例代码中:
@accept_websocket
def echo(request):
if request.is_websocket:
lock = threading.RLock()
try:
lock.acquire()
clients.append(request.websocket)
for message in request.websocket:
if not message:
break
for client in clients:
client.send(message)
finally:
clients.remove(request.websocket)
lock.release()
client.send()传递的是一个什么参数呢?
如何从后端发送更新的消息呢?
Shouldn’t the front-end directly request it regularly?