Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const listener = direct.createListener({ config: {} }, (conn) => {
console.log('[listener] Got connection')
const muxer = mplex.listener(conn)
muxer.on('stream', (stream) => {
console.log('[listener] Got stream')
pull(
stream,
pull.drain((data) => {
console.log('[listener] Received:')
console.log(data.toString())
})
)
})
})
const listener = tcp.createServer((socket) => {
let muxer = mplex.listener(toPull.duplex(socket))
muxer.on('stream', (stream) => {
readWrite(stream)
})
for (let i = 0; i < 100; i++) {
muxer.newStream((err, stream) => {
if (err) {
throw err
}
readWrite(stream)
})
}
socket.on('close', () => {
listener.close()
})
})