使用Djangowebocketredis在服务器端接收数据?

2024-05-20 22:26:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用django websocketredis lib,它允许在分离的django循环中通过uwsgi建立websockets。 根据文档,我很清楚如何通过websockets从服务器发送数据,但我不知道如何接收。在

基本上我有客户机,我想定期从客户机发送到服务器状态。我不明白我需要做什么,在服务器端处理从客户端接收消息?我应该在客户端上使用什么网址?在


Tags: 数据django文档服务器消息客户端客户机websockets
1条回答
网友
1楼 · 发布于 2024-05-20 22:26:51

您可以通过使用从客户机到服务器的周期性ajax调用来实现这一点。根据文档:

A client wishing to trigger events on the server side, shall use XMLHttpRequests (Ajax), as they are much more suitable, rather than messages sent via Websockets. The main purpose for Websockets is to communicate asynchronously from the server to the client.

不幸的是,我无法找到仅使用websocket消息实现它的方法。在

相关问题 更多 >