我正在尝试使用Javascript连接到websocket,我的代码是:
var socket = new WebSocket("wss://messaging.jobdone.net/ws/293/qqyjhcze/websocket");
socket.onopen = function() {
console.log('ok');
}
socket.addEventListener('a', function(e)
{console.log(JSON.parse(e.data))});
socket.send('o')
使用Chrome扩展程序,我收到以下输出:
a["{\"t\":\"auth.token\",\"b\":{\"cid\":\"845ba213-a0c2-4073-9257-7e3883a8c4d2\",\"token\":\"cda495f9fd6e6a547553b91381d58e3c601029989c371cdf39ec3152f3a3e2a7\"}}"]
使用我的js代码,我收到以下消息:
undefined
当我尝试连接到此wss服务器时,如何获得与Chrome扩展程序所示相同的输出?
答案 0 :(得分:0)
尝试一下
socket.send(e.data)
将数据发送到服务器