deps, disabled all server side calls

v1.18.x
barisusakli 10 years ago
parent 347e37a224
commit 82d863b9c8

@ -54,9 +54,10 @@
"semver": "^4.0.3", "semver": "^4.0.3",
"serve-favicon": "^2.1.5", "serve-favicon": "^2.1.5",
"sitemap": "^0.7.4", "sitemap": "^0.7.4",
"socket.io": "^0.9.17", "socket.io": "^1.2.0",
"socket.io-client": "^0.9.17", "socket.io-client": "^1.2.0",
"socket.io-wildcard": "~0.1.1", "socket.io-redis": "^0.1.3",
"socketio-wildcard": "~0.1.1",
"string": "^2.1.0", "string": "^2.1.0",
"templates.js": "0.1.9", "templates.js": "0.1.9",
"uglify-js": "git+https://github.com/julianlam/UglifyJS2.git", "uglify-js": "git+https://github.com/julianlam/UglifyJS2.git",

@ -1,7 +1,7 @@
"use strict"; "use strict";
var SocketIO = require('socket.io'), var SocketIO = require('socket.io'),
socketioWildcard = require('socket.io-wildcard'), socketioWildcard = require('socketio-wildcard'),
util = require('util'), util = require('util'),
async = require('async'), async = require('async'),
path = require('path'), path = require('path'),
@ -22,7 +22,7 @@ var SocketIO = require('socket.io'),
/* === */ /* === */
var io; var io;
var onlineUsers = []; var onlineUsers = [];
@ -76,26 +76,29 @@ Sockets.init = function(server) {
}; };
// If a redis server is configured, use it as a socket.io store, otherwise, fall back to in-memory store // If a redis server is configured, use it as a socket.io store, otherwise, fall back to in-memory store
if (nconf.get('redis')) { // if (nconf.get('redis')) {
var RedisStore = require('socket.io/lib/stores/redis'), // var RedisStore = require('socket.io/lib/stores/redis'),
database = require('../database/redis'), // database = require('../database/redis'),
pub = database.connect(), // pub = database.connect(),
sub = database.connect(), // sub = database.connect(),
client = database.connect(); // client = database.connect();
// "redis" property needs to be passed in as referenced here: https://github.com/Automattic/socket.io/issues/808 // // "redis" property needs to be passed in as referenced here: https://github.com/Automattic/socket.io/issues/808
// Probably fixed in socket.IO 1.0 // // Probably fixed in socket.IO 1.0
config.store = new RedisStore({ // config.store = new RedisStore({
redis: require('redis'), // redis: require('redis'),
redisPub : pub, // redisPub : pub,
redisSub : sub, // redisSub : sub,
redisClient : client // redisClient : client
}); // });
} else if (nconf.get('cluster')) { // } else if (nconf.get('cluster')) {
winston.warn('[socket.io] Clustering detected, you are advised to configure Redis as a websocket store.'); // winston.warn('[socket.io] Clustering detected, you are advised to configure Redis as a websocket store.');
} // }
io = new SocketIO();
io = socketioWildcard(SocketIO).listen(server, config); io.use(socketioWildcard);
//io = socketioWildcard(SocketIO).listen(server, config);
io.listen(server, config);
Sockets.server = io; Sockets.server = io;
@ -112,7 +115,8 @@ Sockets.init = function(server) {
}); });
}); });
io.sockets.on('connection', function(socket) { io.on('connection', function(socket) {
console.log('connection', socket.id);
var hs = socket.handshake, var hs = socket.handshake,
sessionID, uid; sessionID, uid;
@ -256,6 +260,8 @@ Sockets.in = function(room) {
}; };
Sockets.uidInRoom = function(uid, room) { Sockets.uidInRoom = function(uid, room) {
return false;
var userSocketIds = io.sockets.manager.rooms['/uid_' + uid]; var userSocketIds = io.sockets.manager.rooms['/uid_' + uid];
if (!Array.isArray(userSocketIds) || !userSocketIds.length) { if (!Array.isArray(userSocketIds) || !userSocketIds.length) {
return false; return false;
@ -275,6 +281,8 @@ Sockets.uidInRoom = function(uid, room) {
}; };
Sockets.getSocketCount = function() { Sockets.getSocketCount = function() {
return false;
var clients = io.sockets.manager.rooms['']; var clients = io.sockets.manager.rooms[''];
return Array.isArray(clients) ? clients.length : 0; return Array.isArray(clients) ? clients.length : 0;
}; };
@ -284,6 +292,8 @@ Sockets.getConnectedClients = function() {
}; };
Sockets.getUserSocketCount = function(uid) { Sockets.getUserSocketCount = function(uid) {
return 0;
var roomClients = io.sockets.manager.rooms['/uid_' + uid]; var roomClients = io.sockets.manager.rooms['/uid_' + uid];
if(!Array.isArray(roomClients)) { if(!Array.isArray(roomClients)) {
return 0; return 0;
@ -296,6 +306,8 @@ Sockets.getOnlineUserCount = function () {
}; };
Sockets.getOnlineAnonCount = function () { Sockets.getOnlineAnonCount = function () {
return 0;
var guestRoom = io.sockets.manager.rooms['/online_guests']; var guestRoom = io.sockets.manager.rooms['/online_guests'];
if (!Array.isArray(guestRoom)) { if (!Array.isArray(guestRoom)) {
return 0; return 0;
@ -304,6 +316,8 @@ Sockets.getOnlineAnonCount = function () {
}; };
Sockets.getUserSockets = function(uid) { Sockets.getUserSockets = function(uid) {
return [];
var sockets = io.sockets.clients(); var sockets = io.sockets.clients();
if(!sockets || !sockets.length) { if(!sockets || !sockets.length) {
return []; return [];
@ -319,6 +333,8 @@ Sockets.getUserSockets = function(uid) {
}; };
Sockets.getUserRooms = function(uid) { Sockets.getUserRooms = function(uid) {
return {};
var rooms = {}; var rooms = {};
var uidSocketIds = io.sockets.manager.rooms['/uid_' + uid]; var uidSocketIds = io.sockets.manager.rooms['/uid_' + uid];
if (!Array.isArray(uidSocketIds)) { if (!Array.isArray(uidSocketIds)) {
@ -338,22 +354,25 @@ Sockets.getUserRooms = function(uid) {
}; };
Sockets.reqFromSocket = function(socket) { Sockets.reqFromSocket = function(socket) {
var headers = socket.handshake.headers, console.log('socket.request', socket.request);
host = headers.host, return socket.request;
referer = headers.referer || ''; // var headers = socket.handshake.headers,
// host = headers.host,
return { // referer = headers.referer || '';
ip: headers['x-forwarded-for'] || (socket.handshake.address || {}).address,
host: host, // return {
protocol: headers.secure ? 'https' : 'http', // ip: headers['x-forwarded-for'] || (socket.handshake.address || {}).address,
secure: !!headers.secure, // host: host,
url: referer, // protocol: headers.secure ? 'https' : 'http',
path: referer.substr(referer.indexOf(host) + host.length), // secure: !!headers.secure,
headers: headers // url: referer,
}; // path: referer.substr(referer.indexOf(host) + host.length),
// headers: headers
// };
}; };
Sockets.isUserOnline = function(uid) { Sockets.isUserOnline = function(uid) {
return false;
if (!io) { if (!io) {
// Special handling for install script (socket.io not initialised) // Special handling for install script (socket.io not initialised)
return false; return false;
@ -400,6 +419,7 @@ Sockets.updateRoomBrowsingText = function (roomName, selfUid) {
}; };
Sockets.getUidsInRoom = function(roomName) { Sockets.getUidsInRoom = function(roomName) {
return [];
var uids = []; var uids = [];
roomName = roomName ? '/' + roomName : ''; roomName = roomName ? '/' + roomName : '';
var socketids = io.sockets.manager.rooms[roomName]; var socketids = io.sockets.manager.rooms[roomName];

Loading…
Cancel
Save