Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = require('../config.js');
- var users = require('./users.js');
- var Socket = {
- init: function() {
- Socket.io = require('socket.io').listen(config.port);
- },
- on: function(socket, rsa, header, callback) {
- socket.on(header, function(d) {
- var data = JSON.parse(rsa.Decrypt(d));
- callback(data);
- });
- },
- onN: function(socket, rsa, header, callback) {
- var uid = users.getIdBySocketID(socket.id);
- if(uid == false) Socket.on(socket, rsa, header, callback);
- },
- onL: function(socket, rsa, header, callback) {
- var uid = users.getIdBySocketID(socket.id);
- if(uid != false) Socket.on(socket, rsa, header, callback);
- },
- emitClient: function(clientId, header, data) {
- Socket.io.to(clientId).emit(header, data);
- },
- emitAll: function(header, data) {
- Socket.io.sockets.emit(header, data);
- },
- kik: function(socketID) {
- Socket.io.sockets.connected[socketID].disconnect();
- var uid = users.getIdBySocketID(socketID);
- if(uid != false) users.Remove(uid);
- }
- }
- Socket.init();
- module.exports = Socket;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement