add(socket: net.Socket, data: Buffer) { if (this.state !== ST_STARTED) { return; } this.httpServer.emit('connection', socket); if (typeof (socket as any).ondata === 'function') { // compatible with stream2 (socket as any).ondata(data, 0, data.length); } else { // compatible with old stream socket.emit('data', data); } }
process.on('message', function (msg, httpServer) { if (msg === 'server') { httpServer.on('connection', function (socket) { server.emit('connection', socket); }); } });