发送 请求 数据格式,求解
发布于 5个月前 作者 panghoo 452 次浏览 来自 问答
var data = {'name': 'jifeng', 'company': 'taobao'}; 
client.emit('www',JSON.stringify(data));
5:::{"name":"www","args":["{\"name\":\"jifeng\",\"company\":\"taobao\"}"]}

下面这个前面+1 是什么意思 如何写

5:1+::{"name":"post","args":["{\"url\":\"/login\",\"data\":{\"mobile\":\"_silent_\",\"password\":\"_silent_\"}}"]}
15 回复

5:1+:: 这是 log 的输出格式里的吧。请说明出处。

@leapon 在chrome dev tools websocket 监测的数据

@panghoo

看到了,6:::4+[{"msgType":"ack"}] 是输出内容。socket.io的规定格式吧,等牛人解答。 Screen Shot 2014-09-15 at 2.29.35 PM.png

@leapon 你这个6:::4+ 如何写的 我每次什么都是5:::::

@panghoo 我的socket.io通讯中也没有具体到这个层次。你的问题很好,我还没有答案。

socket.on('message', function (msg) {
    socket.broadcast.emit('message', msg);
});

QQ截图20140916094712.png 颜色标识 这是数据交互形式?求解,发送数据 格式是 客户端发送: 5:x+:: {"name":"post","args":[“{"url":"/login","data":{"mobile":”silent“,"password":”silent“}}”]} 服务器返回的 6:::x+[{"error":"用户未登陆"}] 这样的形式

服务器如何写的,谢谢,我在模拟服务端

@leapon 请你找到,你图片那个返回数据的,写法,你给出的不是。。。

找到相关信息了:

Socket.IO Framing Protocol Socket.IO is a great library and framework that doesn’t seem to have a good description of the protocol available. In interest of helping others when they google "socket.io framing protocol", this post was born.

The description of the framing protocol used by Socket.IO below is taken from ajaxorg’s Socket.IO-node fork on github. I have made some changes with regards to the annotations, specifically that they must be terminated by with newline. This description is current for v0.6+.

Socket.IO Framing Protocol

Socket.IO 's framing protocol is on top of the underlying transport. Messages have the following format: (message type)“:”(content length)“:”(data)“,” Where message type is one of:

0 for forced disconnect - no data is sent, always sent as 0:0:, 1 for messages - see below 2 for heartbeats - data is an integer, e.g. 2:1:0, 3 for session ID handshake - data is a session ID, e.g. 3:3:253,

http://blog.shuningbian.net/2011/01/socketio-framing-protocol.html

@leapon 弱弱的问一下。。

我要在websocket数据一样的 信息

6:::1+[{"error":"未登录™†"}]

如何写???

@leapon 按照你上面这个 输出出来是5:::::{name:’message’ xxxxx} 求上面那个。。。。

client.emit('identify’,function(data) {}); 这个前端数据格式我试出来了 5:1+::{"name":"identify"}

client.send('identify’,function(data) {}); 这样写通道就有6:::1

输出 无差别数据

client.on('post’, function(data) { client.emit('post’,data,function(data){}); });

但这个是客户端数据。。没用

回到顶部