ataraxia-ws-server
TypeScript icon, indicating that this package has built-in type declarations

0.12.0 • Public • Published

ataraxia-ws-server

npm version Dependencies Typedoc

Server that allows clients to connect to an Ataraxia network via websockets. This implementation uses ws to serve the websockets. Clients may use a websocket client to connect to the network.

Installation

npm install ataraxia-ws-server

Usage

import { Network, AnonymousAuth } from 'ataraxia';
import { WebSocketServerTransport } from 'ataraxia-ws-server';

// Setup a network with a WebSocket server
const net = new Network({
  name: 'name-of-your-app-or-network',

  transport: [

    new WebSocketServerTransport({
      port: 7000,

      authentication: [
        new AnonymousAuth()
      ]
    })

  ]
});

await net.join();

API

  • new WebSocketServerTransport(options)

    Create a new transport using the given options.

    • options
      • host?: string, hostname where to bind the server.
      • port?: number, port where to bind the server.
      • authentication: AuthProvider[], array of authentication providers.
      • backlog?: number, maximum length of the queue of pending connections.
      • server?: http.Server | https.Server, pre-created Node.js HTTP/S server.
      • verifyClient?: function, a function which can be used to validate incoming connections. See WS docs for details.
      • handleProtocols?: function, a function which can be used to handle the WebSocket subprotocols. See WS docs for details.
      • noServer?: boolean, enable no server mode.
      • clientTracking?: boolean, specifies whether or not to track clients.
      • perMessageDeflate: boolean|object, enable/disable permessage-deflate. See WS docs for details.
      • maxPayload: number, the maximum allowed message size in bytes.

    WebSocketServerTransport extends the options of WebSocket.Server. Detailed description of many of these options can be find in its documentation.

Readme

Keywords

none

Package Sidebar

Install

npm i ataraxia-ws-server

Weekly Downloads

0

Version

0.12.0

License

MIT

Unpacked Size

44 kB

Total Files

16

Last publish

Collaborators

  • aholstenson