View difference between Paste ID: wpmbKeAA and MzPiahiJ
SHOW: | | - or go back to the newest paste.
1-
/********************************
1+
2-
 * FiveHabbo project
2+
3-
 * Recreating Habbo in Javascript
3+
4-
********************************/
4+
5
		Socket.io = require('socket.io').listen(config.port);
6
	},
7
	on: function(socket, rsa, header, callback) {
8
		socket.on(header, function(d) {
9
			var data = JSON.parse(rsa.Decrypt(d));
10
			callback(data);
11
		});
12
	},
13
	onN: function(socket, rsa, header, callback) {
14
		var uid = users.getIdBySocketID(socket.id);
15
    	if(uid == false) Socket.on(socket, rsa, header, callback);
16
	},
17
	onL: function(socket, rsa, header, callback) {
18
		var uid = users.getIdBySocketID(socket.id);
19
    	if(uid != false) Socket.on(socket, rsa, header, callback);
20
	},
21
	emitClient: function(clientId, header, data) {
22
		Socket.io.to(clientId).emit(header, data);
23
	},
24
	emitAll: function(header, data) {
25
		Socket.io.sockets.emit(header, data);
26
	},
27
	kik: function(socketID) {
28
		Socket.io.sockets.connected[socketID].disconnect();
29
		var uid = users.getIdBySocketID(socketID);
30
    	if(uid != false) users.Remove(uid);
31
	}
32
}
33
Socket.init();
34
module.exports = Socket;