当前测试人数
new WebSocket("ws://link.ibeeger.com/ws?token=89414b156e300f169462647ed7106d326a8d641e&key=ceshizhanghao&cid=xxxxxxx");
ws.send(JSON.stringify({type:"TOCID",cid:"cid",data:"xxxxxxx消息内容"}));//给该key下指定在线用户发送消息 ws.send(JSON.stringify({type:"TOALL",data:"xxxxxxx消息内容"}));//给该key下的所用在线用户发送消息;
ws.onmessage = getmsg; function getmsg(msg){ var json = JSON.parse(msg.data); console.log(json); switch(json["code"]){ case 9 : json["data"] // 错误消息; break; case 8 : json["data"] //在线人数 break; case 0 : console.log(json["data"]);//消息 break; default: console.log(json["data"]); } }