0.12.0 • Published 2 years ago

ataraxia-ws-server v0.12.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

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.

0.12.0

2 years ago

0.11.0

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.9.1

3 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.1

6 years ago

0.6.0

6 years ago