fix reqFromSocket for socket.io 1.x

v1.18.x
barisusakli 10 years ago
parent 2c89d50322
commit 13609edf82

@ -87,6 +87,8 @@ Sockets.init = function(server) {
io.on('connection', function(socket) { io.on('connection', function(socket) {
console.log('CONNECTED', socket.uid, socket.id); console.log('CONNECTED', socket.uid, socket.id);
socket.ip = socket.request.connection.remoteAddress;
logger.io_one(socket, socket.uid); logger.io_one(socket, socket.uid);
if (socket.uid) { if (socket.uid) {
@ -306,21 +308,19 @@ Sockets.getUserRooms = function(uid) {
}; };
Sockets.reqFromSocket = function(socket) { Sockets.reqFromSocket = function(socket) {
console.log('socket.request', socket.request); var headers = socket.request.headers,
return socket.request; host = headers.host,
// var headers = socket.handshake.headers, referer = headers.referer || '';
// host = headers.host,
// referer = headers.referer || ''; return {
ip: socket.ip,
// return { host: host,
// ip: headers['x-forwarded-for'] || (socket.handshake.address || {}).address, protocol: socket.request.connection.encrypted ? 'https' : 'http',
// host: host, secure: !!socket.request.connection.encrypted,
// protocol: headers.secure ? 'https' : 'http', url: referer,
// secure: !!headers.secure, path: referer.substr(referer.indexOf(host) + host.length),
// url: referer, headers: headers
// path: referer.substr(referer.indexOf(host) + host.length), };
// headers: headers
// };
}; };
Sockets.isUserOnline = function(uid) { Sockets.isUserOnline = function(uid) {

Loading…
Cancel
Save