成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

python - Django利用dwebsocket實現(xiàn)后臺數(shù)據(jù)更新實時更新到前端?

瀏覽:103日期:2022-09-01 13:50:55

問題描述

實現(xiàn)的功能是django后臺數(shù)據(jù)更新之后,例如說一個群組人員增加,不刷新頁面實現(xiàn)推送消息的功能,但是不是很懂dwebsocket的機制:

給的實例代碼中:

@accept_websocketdef 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()傳遞的是一個什么參數(shù)呢?如何從后端發(fā)送更新的消息呢?

問題解答

回答1:

不是應該前端直接定時請求的么?

標簽: Python 編程
相關文章: