企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script src="/socket.io/socket.io.js"></script> <script> var socket = io('http://localhost:8080'); //监听服务消息 socket.on('msg', function (data) { console.log(data); socket.emit('msg', "hello server"); }); //正在连接 socket.on('connecting', function () { console.log("正在连接") }); //连接成功 socket.on('connect', function () { console.log("连接成功"); }); //监听socket断开 socket.on('disconnect', function () { console.log("与服务器断开连接"); }); //连接失败 socket.on('connect_failed', function () { console.log("连接失败"); }); //发生错误 socket.on('error', function () { console.log("发生错误"); }); //重连 socket.on('reconnect', function () { console.log("重新成功") }); //正在重连 socket.on('reconnecting', function () { console.log("正在重连....") }); //重连失败 socket.on('reconnect_failed', function () { console.log("重连失败") }); </script> </body> </html> ~~~