๐Ÿ” nlon-websocket

Classes

WebSocketStream โ‡ stream.Duplex

A Duplex stream implementation wrapping a WebSocket.

WebSocketWrapperPeer โ‡ nlon.Peer

A WebSocket-specific extension of nlon.Peer

WebSocketWrapperServer โ‡ nlon.Server

A WebSocket-specific extension of nlon.Server.

Functions

createWebSocketPeer (options) โ‡’ WebSocketWrapperPeer

Create nlon peer managing a WebSocket.

createWebSocketServer (options) โ‡’ WebSocketWrapperServer

Create an nlon server listening on WebSocket.

wrapWebSocketPeer (socket, options) โ‡’ WebSocketWrapperPeer
wrapWebSocketServer (server, options) โ‡’ WebSocketWrapperServer

Typedefs

WebSocketOptions : object

External

nlon.Peer
nlon.PeerOptions
nlon.Server
nlon.ServerOptions
stream.Duplex
ws.WebSocket
ws.WebSocketServer

WebSocketStream โ‡ stream.Duplex

A Duplex stream implementation wrapping a WebSocket.

This class can be used to treat a WebSocket as a regular stream. Under the hood it subscribes to the WebSocket's events and forwards any writes.

Kind: global class

Extends: stream.Duplex

constructor WebSocketStream

Wrap a WebSocket.

ParamTypeDescription
wsWebSocket

WebSocket to wrap

optionsstream.DuplexOptions

Stream options

WebSocketStream#ws : WebSocket

Get the underlying WebSocket.

Kind: instance member


WebSocketWrapperPeer โ‡ nlon.Peer

A WebSocket-specific extension of nlon.Peer

This class is an nlon Peer that wraps and manages a WebSocket instance. All messages arriving on the socket will be processed and all outbound traffic will be sent on it.

The underlying WebSocket can also be accessed using .stream.

This class shouldn't be instantiated directly, instead use the factory methods.

Kind: global class

Extends: nlon.Peer

See:

WebSocketWrapperPeer#stream : ws.WebSocket

The underlying WebSocket.

Kind: instance member


WebSocketWrapperServer โ‡ nlon.Server

A WebSocket-specific extension of nlon.Server.

This class functions exactly the same as nlon.Server, with the addition that it keeps a reference to a WebSocketStream which can be accessed through the server field.

Any incoming WebSocket connection will be wrapped in WebSocketStream and connected to the nlon server.

This class shouldn't be instantiated directly, instead use the factory methods.

Kind: global class

Extends: nlon.Server

See:

WebSocketWrapperServer#stream : ws.WebSocketServer

The underlying server.

Kind: instance member

createWebSocketPeer (options) โ‡’ WebSocketWrapperPeer

Create nlon peer managing a WebSocket.

This method will create a new WebSocket and wrap it in an nlon Peer. The created socket will automatically connect to the address specified.

The options parameter will be used to create the WebSocket and will be passed to the nlon Peer as settings.

Kind: global function

ParamTypeDescription
optionsnlon.PeerOptions, WebSocketOptions

Options


createWebSocketServer (options) โ‡’ WebSocketWrapperServer

Create an nlon server listening on WebSocket.

The WebSocket server will be automatically created based on the input options. Under the hood, the ws package is used, which also means that depending on the options, an HTTP server will be launched.

The options parameter will be used to both create the WebSocket server and the nlon server.

Kind: global function

ParamTypeDescription
optionsnlon.ServerOptions, ws.ServerOptions

Options


wrapWebSocketPeer (socket, options) โ‡’ WebSocketWrapperPeer

Wrap an existing WebSocket with an nlon Peer.

Kind: global function

ParamTypeDescription
socketws.WebSocket
optionsnlon.PeerOptions

wrapWebSocketServer (server, options) โ‡’ WebSocketWrapperServer

Wrap an existing WebSocketServer as an nlon Server.

Kind: global function

ParamTypeDescription
serverws.WebSocketServer

WebSocket server

optionsnlon.ServerOptions

nlon server options

WebSocketOptions : object

Kind: global typedef

PropertyTypeDescription
addressstring
[protocols]string, Array.<string>

nlon.Peer

An nlon Peer.

Kind: global external

See: http://elementbound.github.io/nlon/reference/nlon/#class-Peer


nlon.PeerOptions

Options for an nlon Peer.

Kind: global external

See: http://elementbound.github.io/nlon/reference/nlon/#typedef-PeerOptions


nlon.Server

An nlon Server.

Kind: global external

See: http://elementbound.github.io/nlon/reference/nlon/#class-Server


nlon.ServerOptions

Options for an nlon Server.

Kind: global external

See: http://elementbound.github.io/nlon/reference/nlon/#typedef-ServerOptions


stream.Duplex

Duplex stream.

Kind: global external

See: https://nodejs.org/api/stream.html#class-streamduplex


ws.WebSocket

Kind: global external

See: https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocket


ws.WebSocketServer

Kind: global external

See: https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocketserver

results matching ""

    No results matching ""