Skip to content

Commit

Permalink
fix zero footprint node server issue
Browse files Browse the repository at this point in the history
  • Loading branch information
e9gille committed Oct 19, 2017
1 parent c27ba14 commit fcf2f9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions srv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const app=express(),port=8443,cert=fs.readFileSync('ssl/cert.pem'),key=fs.readFi
app.disable('x-powered-by');app.use((x,_,f)=>{log(x.method+' '+x.path);f()})
app.use(rq('compression')());app.use('/',express.static('.'))
const hsrv=rq('https').createServer({cert,key},app)
let wskt //websocket connection
;(new rq('ws').Server({server:hsrv})).on('connection',x=>{wskt=x;x.on('message',y=>sendEach([y]))})
let wskt,ws=rq('ws') //websocket connection
;(new ws.Server({server:hsrv})).on('connection',x=>{wskt=x;x.on('message',y=>sendEach([y]))})
hsrv.listen(port,_=>log('http server listening on port '+port))
const maxl=100,trunc=x=>x.length>maxl?x.slice(0,maxl-3)+'...':x //helper for logging
,toBuf=x=>{const b=Buffer('xxxxRIDE'+x);b.writeInt32BE(b.length,0);return b} //serialize in a RIDE protocol envelope
Expand Down

0 comments on commit fcf2f9b

Please sign in to comment.