moved reconnected socket call to SocketsMeta

v1.18.x
Julian Lam 11 years ago
parent 99af660e48
commit ee963e0c2a

@ -77,7 +77,7 @@ var socket,
}
app.enterRoom(room, true);
socket.emit('reconnected');
socket.emit('api:meta.reconnected');
setTimeout(function() {
reconnectEl.removeClass('active').addClass("hide");

@ -119,21 +119,6 @@ Sockets.init = function() {
}
});
socket.on('reconnected', function() {
if (uid) {
topics.pushUnreadCount(uid);
user.pushNotifCount(uid);
}
if (process.env.NODE_ENV === 'development') {
if (uid) {
winston.info('[socket] uid ' + uid + ' (' + sessionID + ') has successfully reconnected.');
} else {
winston.info('[socket] An anonymous user (' + sessionID + ') has successfully reconnected.');
}
}
});
socket.on('*', function(payload, callback) {
// Ignore all non-api messages
if (payload.name.substr(0, 4) !== 'api:') {

@ -1,13 +1,33 @@
var meta = require('../meta'),
user = require('../user'),
topics = require('../topics'),
logger = require('../logger'),
plugins = require('../plugins'),
nconf = require('nconf'),
gravatar = require('gravatar'),
winston = require('winston'),
SocketMeta = {};
SocketMeta.reconnected = function(sessionData) {
var uid = sessionData.uid,
sessionID = sessionData.socket.id;
if (uid) {
topics.pushUnreadCount(uid);
user.pushNotifCount(uid);
}
if (process.env.NODE_ENV === 'development') {
if (uid) {
winston.info('[socket] uid ' + uid + ' (' + sessionID + ') has successfully reconnected.');
} else {
winston.info('[socket] An anonymous user (' + sessionID + ') has successfully reconnected.');
}
}
};
SocketMeta.buildTitle = function(text, callback) {
meta.title.build(text, function(err, title) {
callback(title);

Loading…
Cancel
Save