nl_tokens: Creates a RoboHydra server similar to http . createServer or https . createServer . The returned object is in fact the same as with the createServer so the same methods ( listen on etc . ) can be used .
pl_tokens: function createRoboHydraServer ( config , extraVars ) { var summoner ; try { summoner = new RoboHydraSummoner ( config . plugins , config . summoner , { extraVars : extraVars , extraPluginLoadPaths : config . pluginLoadPaths } ) ; } catch ( e ) { console . error ( e . message || e ) ; process . <mask> ( 1 ) ; } // This merely forces a default Hydra to be created. It's nice because // it forces plugins to be loaded, and we get plugin loading errors // early summoner . summonRoboHydraForRequest ( new Request ( { url : "/" } ) ) ; var handler = makeRequestHandler ( config , summoner ) , server ; if ( config . secure ) { var keyPath = config . sslOptions . key , certPath = config . sslOptions . cert ; if ( ! keyPath ) { throw new Error ( "Need sslOptions.key if secure is set to true" ) ; } if ( ! certPath ) { throw new Error ( "Need sslOptions.cert if secure is set to true" ) ; } server = https . createServer ( { key : fs . readFileSync ( keyPath ) , cert : fs . readFileSync ( certPath ) } , handler ) ; } else { server = http . createServer ( handler ) ; } var wsServer = new WebSocketServer ( { server : server } ) ; wsServer . on ( "connection" , function ( client ) { // Make sure there's at least one handler for the 'error' // event so that the server doesn't die when a client closes // the websocket connection client . on ( "error" , function ( ) { } ) ; summoner . summonRoboHydraForRequest ( client . upgradeReq ) . webSocketHandle ( client . upgradeReq , client ) ; } ) ; return server ; }