Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 2.58 KB

protocol.md

File metadata and controls

43 lines (25 loc) · 2.58 KB

请求弹幕服务器,获取基本值(rid,appid,authtype,ip,port,sign,ts)

使用http协议请求http://www.panda.tv/ajax_chatinfo 参数为roomid=房间号

eg: 请求:http://www.panda.tv/ajax_chatinfo?roomid=313180

响应:{"errno":0,"data":{"rid":27742018,"appid":845694055,"authtype":"3","chat_addr_list":["180.163.220.15:443","180.163.220.15:443"],"sign":"59240676592e351a3be3549aba8579c5","ts":"1456754823867"},"errmsg":""}

建立连接(socket):

前面得到的数据,发送连接请求

标志起始♥ 后面的数据的长度 u:
rid的值 @
appid值 \n
k:1\n
t:300\n
ts:
ts的值 \n
sign:
sign的值 \n
authtype:
authtype的值
00 06 00 02 00 61 75 3A 2D 38 38 35 36 33 34 38 39 40 31 35 38 32 36 30 30 35 35 0A 6B 3A 31 0A 74 3A 33 30 30 0A 74 73 3A 31 34 35 36 37 35 32 33 37 38 39 35 30 0A 73 69 67 6E 3A 34 30 30 36 39 39 66 35 65 33 31 39 62 62 36 32 38 66 39 38 38 62 36 38 35 38 33 30 33 35 65 34 0A 61 75 74 68 74 79 70 65 3A 33

带♥号的表示值为固定值

获得返回值

是否连接成功 数据主体的长度 返回的数据主体
0x00060006:成功 eg:16 appid的值+r的值 eg:id:845694055\nr:0

心跳(保持连接不中断)

服务器定时发送0x00060000即可(间隔本程序采用300s)

弹幕消息

在与弹幕服务器建立了连接之后,即可以与服务进行通信, 服务器向客户端发送弹幕消息,帧格式为:

功能码 消息体1长度 消息体1 消息体2长度 消息体2前部分 消息体2后部分(消息内容)(json格式)
4字节 2字节 4字节 16字节
0x00060001:
0x00060003:弹幕消息
eg:
ack:0
eg:{
"type":"1",
"time":1456824617,
"data":{
"from":{
"identity":"30",
"rid":"27742018",
"__plat":"pc_web",
"nickName":"neucrack",
"level":"2",

"userName":"PandaTv27742018"
},
"to":{
"toqid":1,
"toroom":"313180"
},
"content":"55555"
}
}