blob: af05ad9905c9d0fe7e1d2ea894b48afbc5514bea (
plain)
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
34
35
36
37
38
39
40
41
42
43
|
var socket = io.connect(window.location.hostname);
var Game = {
nick: null,
init: function(){
// Bind events from the server
socket.on('event-join', Events.receive.join);
socket.on('event-message', Events.receive.message);
Auth.init();
Chat.init();
}
}
var Events = {
receive: {
join: function(data){
for (var i in data.messages) {
Chat.add(data.messages[i]);
}
},
message: function(msg){
Chat.add(msg);
}
},
send: {
message: function(msg) {
socket.emit('event-message', msg);
}
},
};
$(Game.init);
|