rx-net
Common net operations using Reactive Extensions.
server
Listens on a host and port, returning a stream of sessions. Unsubscribing will stop listening.
Optionally calls a callback when server begins listening.
Usage:
client
Connects to a host and port, returning a session.
Optionally calls a callback when connection succeeds.
Usage:
const session =
session
Whether emitted by a server stream, or created by calling client, the session object handles communication back and forth to the peer.
Observable<Buffer>
outputStream: This is the stream of messages being sent by your code. You do not need to directly interact with this stream.
Observable<Buffer>
inputStream: Stream of incoming packets from the peer.
send(data)
Sends data to the peer. Can pass a Buffer
, Array<Buffer>
, or Observable<Buffer>
.
close()
Ends the connection with the peer.
Full sample
const net = const hodor = { sessioninputStream session}const startServer = { const subscription = net }const startClient = { net}