1234567891011121314151617181920212223242526 |
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title></title>
- <script src="js/socket.io.min.js"></script>
- </head>
- <body>
- <script>
- var socket = io.connect("ws://192.168.3.92:8088", { path: "onlinewebsocket/123456" })
- socket.on('error', function (data) {
- console.log(JSON.stringify(data) + ' - error');
- });
- socket.on('disconnect', function (data) {
- //失去连接的事件
- console.log(JSON.stringify(data) + ' - disconnect');
- });
- socket.on('reconnect', function (data) {
- //重新连接的事件
- console.log(JSON.stringify(data) + ' - reconnect');
- socket.emit('userReg', userMsg);
- });
- socket.emit('userReg', "123");
- </script>
- </body>
- </html>
|