UNPKG

scalra

Version:

node.js framework to prototype and scale rapidly

64 lines (49 loc) 1.24 kB
// // system.js // // system related operations (during server start/stop) // // history: // 2016-01-12 first version extracted from frontier.js // // module object var l_module = exports.module = {}; // a pool for all message handlers var l_handlers = exports.handlers = {}; var l_checkers = exports.checkers = {}; var l_name = 'SR.Module.system'; //----------------------------------------- // API // //----------------------------------------- //----------------------------------------- // Server Event Handling // //----------------------------------------- SR.Callback.onStart(function () { // tasks when server starts }); SR.Callback.onStop(function () { // tasks when server stops }); // when a client connects SR.Callback.onConnect(function (conn) { // do some config checking & init }); // when a client disconnects SR.Callback.onDisconnect(function (conn) { // handle disconnect }); // module init l_module.start = function (config, onDone) { // process config & verify correctness here // enable console handler if (config.console !== false) SR.Console.init(); UTIL.safeCall(onDone); } // module shutdown l_module.stop = function (onDone) { // close / release resources used UTIL.safeCall(onDone); }