kopia lustrzana https://github.com/c9/core
Adding more documentation and ensure there is only one socket.close listener
rodzic
227f1b7a57
commit
0c99cd47b2
|
@ -154,6 +154,7 @@ Vfs.prototype._createEngine = function(vfs, options) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.keepAliveTimer = null;
|
this.keepAliveTimer = null;
|
||||||
|
var listeningForEIOSocketClose = false;
|
||||||
|
|
||||||
this.workers = 0;
|
this.workers = 0;
|
||||||
|
|
||||||
|
@ -169,21 +170,29 @@ Vfs.prototype._createEngine = function(vfs, options) {
|
||||||
that.socket.disconnect();
|
that.socket.disconnect();
|
||||||
|
|
||||||
that.socket = socket;
|
that.socket = socket;
|
||||||
if (socket.socket) { // socket is the reliablesocket, socket.socket is the reconnectsocket, socket.socket.socket is engineio's socket
|
/* - socket is the reliablesocket,
|
||||||
var listenEIOSocket = function (eioSocket) {
|
- socket.socket is the reconnectsocket,
|
||||||
if (!eioSocket) return;
|
- socket.socket.socket is engineio's socket */
|
||||||
eioSocket.on("close", function (reason, description) {
|
if (socket.socket) {
|
||||||
|
/* Add listener to core Engine.io socket used for user communication
|
||||||
|
to track and log all reasons causing it to close so when users
|
||||||
|
complain about disconnects we can investigate what's causing them */
|
||||||
|
var listenForEIOSocketClose = function (eioSocket) {
|
||||||
|
if (!eioSocket || listeningForEIOSocketClose) return;
|
||||||
|
eioSocket.once("close", function (reason, description) {
|
||||||
var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid};
|
var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid};
|
||||||
console.log("Socket closed", logMetadata);
|
console.log("Socket closed", logMetadata);
|
||||||
logMetadata.message = "Socket closed";
|
logMetadata.message = "Socket closed";
|
||||||
that.logger.log(logMetadata);
|
that.logger.log(logMetadata);
|
||||||
|
listeningForEIOSocketClose = false;
|
||||||
});
|
});
|
||||||
|
listeningForEIOSocketClose = true;
|
||||||
};
|
};
|
||||||
socket.socket.on('away', function() {
|
socket.socket.once('away', function() {
|
||||||
listenEIOSocket(socket.socket.socket);
|
listenForEIOSocketClose(socket.socket.socket);
|
||||||
});
|
});
|
||||||
socket.socket.on('back', function() {
|
socket.socket.once('back', function() {
|
||||||
listenEIOSocket(socket.socket.socket);
|
listenForEIOSocketClose(socket.socket.socket);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
socket.on('disconnect', function (err) {
|
socket.on('disconnect', function (err) {
|
||||||
|
|
Ładowanie…
Reference in New Issue