-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
33 lines (31 loc) · 887 Bytes
/
index.html
File metadata and controls
33 lines (31 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script src='http://cdn.bootcss.com/socket.io/1.3.7/socket.io.js'></script>
<script src='http://cdn.bootcss.com/jquery/1.11.3/jquery.js'></script>
</head>
<body>
<script>
$(document).ready(function () {
var uid = 987859263;
// 连接服务端
var socket = io('http://192.168.1.228:2120');
// 连接后登录
socket.on('connect', function(){
socket.emit('login', uid);
});
// 后端推送来消息时
socket.on('new_msg', function(msg){
$('#bbb').html('收到消息:'+msg);
});
// 后端推送来在线数据时
socket.on('update_online_count', function(online_stat){
$('#online_box').html(online_stat);
});
});
</script>
<center id="online_box"></center>
<center id="bbb"></center>
</body>
</html>