|
|
|
@ -9,6 +9,16 @@ module.exports.create = function (config) {
|
|
|
|
|
|
|
|
|
|
var log = config.log;
|
|
|
|
|
|
|
|
|
|
var noop = function () {};
|
|
|
|
|
|
|
|
|
|
var special_errors = {};
|
|
|
|
|
['EPIPE', 'ECONNRESET'].forEach(function (k) { special_errors[k] = noop; });
|
|
|
|
|
special_errors.NF_ENOENT = function (error, label, info) {
|
|
|
|
|
log.error(label, {
|
|
|
|
|
info: info,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// spawn ws server and attach netflux event handlers
|
|
|
|
|
NetfluxSrv.create(new WebSocketServer({ server: config.httpServer}))
|
|
|
|
|
.on('channelClose', historyKeeper.channelClose)
|
|
|
|
@ -17,11 +27,17 @@ module.exports.create = function (config) {
|
|
|
|
|
.on('sessionClose', historyKeeper.sessionClose)
|
|
|
|
|
.on('error', function (error, label, info) {
|
|
|
|
|
if (!error) { return; }
|
|
|
|
|
if (['EPIPE', 'ECONNRESET'].indexOf(error && error.code) !== -1) { return; }
|
|
|
|
|
if (error && error.code) {
|
|
|
|
|
/* EPIPE,ECONNERESET, NF_ENOENT */
|
|
|
|
|
if (typeof(special_errors[error.code]) === 'function') {
|
|
|
|
|
return void special_errors[error.code](error, label, info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* labels:
|
|
|
|
|
SEND_MESSAGE_FAIL, SEND_MESSAGE_FAIL_2, FAIL_TO_DISCONNECT,
|
|
|
|
|
FAIL_TO_TERMINATE, HANDLE_CHANNEL_LEAVE, NETFLUX_BAD_MESSAGE,
|
|
|
|
|
NETFLUX_WEBSOCKET_ERROR, NF_ENOENT
|
|
|
|
|
NETFLUX_WEBSOCKET_ERROR
|
|
|
|
|
*/
|
|
|
|
|
log.error(label, {
|
|
|
|
|
code: error.code,
|
|
|
|
|