0.12.0 • Published 3 years ago

ataraxia-ws-client v0.12.0

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

ataraxia-ws-client

npm version Dependencies Typedoc

Client that connects to a Ataraxia network using a websocket. This module makes it possible for NodeJS-instances (using ws) and browsers to connect to a network running websocket server.

Installation

npm install ataraxia-ws-client

Usage

import { Network, AnonymousAuth } from 'ataraxia';
import { WebSocketClientTransport } from 'ataraxia-ws-client';

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

  transports: [
  
    new WebSocketClientTransport({
      // URL to the websocket on the server
      url: 'ws://localhost:7000',
      // If using outside a browser, define how a WebSocket is created
      factory: url => new WebSocket(url),
      // Use anonymous authentication
      authentication: [
        new AnonymousAuth()
      ]
    })

  ]
});

await net.join();

API

  • new WebSocketClientTransport(options)

    Create a new instance of this transport.

    • options
      • url: string, the URL to connect to, this will be where a WebSocketServerTransport is running.
      • factory?: (url) => WebSocket, factory used to create a WebSocket instance, used to support running both in a browser and in Node via libraries such as ws.
      • authentication: AuthProvider[], array containing all of the authentication methods supported.
0.12.0

3 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.9.1

4 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.1

7 years ago

0.6.0

7 years ago