-
Notifications
You must be signed in to change notification settings - Fork 0
/
sockets.js
39 lines (28 loc) · 1009 Bytes
/
sockets.js
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
// get the chat controller
var Chat = require( './controllers/Chat.js' );
io = module.parent.exports.io;
passportSocketIo = module.parent.exports.passportSocketIo;
sessionStore = module.parent.exports.sessionStore;
sessionOptions = module.parent.exports.sessionOptions;
io.set( 'authorization', passportSocketIo.authorize(sessionOptions) );
io.sockets.on( 'connection', function(socket) {
var user = socket.handshake.user.username;
socket.on( 'joinChat', function(data) {
Chat.joinChat( JSON.parse(data, socket) );
} );
socket.on( 'newmsg', function(data) {
Chat.newMsg( JSON.parse(data), user );
} );
/*
( function(socket, user) {
socket.on( 'joinChat', function(data) {
Chat.joinChat( JSON.parse(data, socket) );
} );
} )(socket, user);
( function(socket, user) {
socket.on( 'newmsg', function(data) {
Chat.newMsg( JSON.parse(data), user );
} );
} )(socket, user)
*/
} );