ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
1.用户登录成功后 app需要与本平台进行socket通信 2.socket连接成功后需要发送以下"json字符"串给本平台 **mac_uuid为设备唯一编码** iris-websocket-message:chat;0; {"type":"login","account":"用户账号","mac_uuid":"xxxxxxxxxxx"} 3.本平台收到数据后将回复一下json信息 iris-websocket-message:chat;0;{"message":"","status":"success","type":"login"} 4.即表示socket通信成功(可以多台设备登陆同一个账号) 5.再本平台收到订单信息后将通过本socket推送给app (多台同账号设备) 6.订单信息如下 iris-websocket-message:chat;0;{"message":"906|123456","status":"success","type":"pushOrder"} message为 订单金额(分)|订单号 **socket地址: ws:localhost:8181/ws** **示例地址:http://localhost:8181/order/socket?account=cuijun** 示例代码demo ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>socket</title> <script src="https://cdn.bootcss.com/jquery/1.2.3/jquery.min.js"></script> <script src="http://localhost:8181/iris-ws.js"></script> </head> <body> <div id="msg">查看Console控制台</div> </body> <script> $(document).ready(function () { /** * webscoket 业务 * @type {string} */ var wsURL = "ws:localhost:8181/ws"; var socket = new Ws(wsURL); socket.OnConnect(function () { console.log("OnConnect"); //数据发送 socket.Emit("chat", JSON.stringify({"type": "login","account":{{.account}}})); }); socket.OnDisconnect(function () { console.log("OnDisconnect"); }); //数据接收 socket.On("chat", function (msg) { var pushData = JSON.parse(msg); if (typeof pushData == "object"){ console.log("receive: " + msg); } }); }); </script> </html> ~~~