mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
removed event:disconnect
This commit is contained in:
@@ -17,28 +17,29 @@ app.isConnected = false;
|
|||||||
|
|
||||||
socket = io(config.websocketAddress, ioParams);
|
socket = io(config.websocketAddress, ioParams);
|
||||||
|
|
||||||
socket.on('connect', onSocketConnect);
|
socket.on('connect', onConnect);
|
||||||
|
|
||||||
socket.on('reconnecting', onReconnecting);
|
socket.on('reconnecting', onReconnecting);
|
||||||
|
|
||||||
|
socket.on('disconnect', onDisconnect);
|
||||||
|
|
||||||
socket.on('reconnect_failed', function() {
|
socket.on('reconnect_failed', function() {
|
||||||
// Wait ten times the reconnection delay and then start over
|
// Wait ten times the reconnection delay and then start over
|
||||||
setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10);
|
setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('event:disconnect', onEventDisconnect);
|
|
||||||
|
|
||||||
socket.on('event:banned', onEventBanned);
|
socket.on('event:banned', onEventBanned);
|
||||||
|
|
||||||
socket.on('event:logout', app.logout);
|
socket.on('event:logout', app.logout);
|
||||||
|
|
||||||
socket.on('event:alert', app.alert);
|
socket.on('event:alert', app.alert);
|
||||||
|
|
||||||
function onSocketConnect() {
|
function onConnect() {
|
||||||
|
app.isConnected = true;
|
||||||
|
|
||||||
if (!reconnecting) {
|
if (!reconnecting) {
|
||||||
app.showLoginMessage();
|
app.showLoginMessage();
|
||||||
$(window).trigger('action:connected');
|
$(window).trigger('action:connected');
|
||||||
app.isConnected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reconnecting) {
|
if (reconnecting) {
|
||||||
@@ -52,7 +53,6 @@ app.isConnected = false;
|
|||||||
|
|
||||||
socket.emit('meta.reconnected');
|
socket.emit('meta.reconnected');
|
||||||
|
|
||||||
app.isConnected = true;
|
|
||||||
$(window).trigger('action:reconnected');
|
$(window).trigger('action:reconnected');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@@ -95,7 +95,7 @@ app.isConnected = false;
|
|||||||
app.enterRoom(room);
|
app.enterRoom(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onReconnecting(attempt) {
|
function onReconnecting() {
|
||||||
reconnecting = true;
|
reconnecting = true;
|
||||||
var reconnectEl = $('#reconnect');
|
var reconnectEl = $('#reconnect');
|
||||||
|
|
||||||
@@ -108,10 +108,9 @@ app.isConnected = false;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEventDisconnect() {
|
function onDisconnect() {
|
||||||
$(window).trigger('action:disconnected');
|
$(window).trigger('action:disconnected');
|
||||||
app.isConnected = false;
|
app.isConnected = false;
|
||||||
socket.connect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEventBanned() {
|
function onEventBanned() {
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ authenticationController.register = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var uid;
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
if (registrationType === 'invite-only') {
|
if (registrationType === 'invite-only') {
|
||||||
@@ -255,7 +254,6 @@ authenticationController.localLogin = function(req, username, password, next) {
|
|||||||
authenticationController.logout = function(req, res, next) {
|
authenticationController.logout = function(req, res, next) {
|
||||||
if (req.user && parseInt(req.user.uid, 10) > 0 && req.sessionID) {
|
if (req.user && parseInt(req.user.uid, 10) > 0 && req.sessionID) {
|
||||||
var uid = parseInt(req.user.uid, 10);
|
var uid = parseInt(req.user.uid, 10);
|
||||||
require('../socket.io').logoutUser(req.user.uid);
|
|
||||||
db.sessionStore.destroy(req.sessionID, function(err) {
|
db.sessionStore.destroy(req.sessionID, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ User.banUser = function(uid, callback) {
|
|||||||
|
|
||||||
websockets.in('uid_' + uid).emit('event:banned');
|
websockets.in('uid_' + uid).emit('event:banned');
|
||||||
|
|
||||||
websockets.logoutUser(uid);
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -193,7 +192,6 @@ User.deleteUsers = function(socket, uids, callback) {
|
|||||||
ip: socket.ip
|
ip: socket.ip
|
||||||
});
|
});
|
||||||
|
|
||||||
websockets.logoutUser(uid);
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -206,10 +206,6 @@ function callMethod(method, socket, params, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Sockets.logoutUser = function(uid) {
|
|
||||||
io.in('uid_' + uid).emit('event:disconnect');
|
|
||||||
};
|
|
||||||
|
|
||||||
Sockets.in = function(room) {
|
Sockets.in = function(room) {
|
||||||
return io.in(room);
|
return io.in(room);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user