如何在打开连接时从Javascript发送一些额外的数据,比如用户名或时间?

2024-06-07 17:07:35 发布

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

如何在打开连接时从Javascript发送一些额外的数据,比如用户名或时间?在

conn = new SockJS('http://' + window.location.host + '/chat', 'websocket');

我也试过了

^{pr2}$

服务器上的Python/Tornado-side函数

class ChatConnection(sockjs.tornado.SockJSConnection):
    def on_open(self, info):
        # some code to broadcast data, but info is empty in both cases
        pass 

Tags: 数据infohttphostnew时间chatlocation

热门问题