Options
All
  • Public
  • Public/Protected
  • All
Menu

Transport that connects to the network over a web socket. This type of transport requires a URL to connect to and the authentication methods to use.

For use outside browsers a function that creates a WebSocket instance may be provided.

Example:

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();

Hierarchy

Index

Constructors

constructor

Properties

Protected debug

debug: Debugger

Protected Readonly peers

peers: Set<Peer>

Accessors

onPeerConnect

  • get onPeerConnect(): Subscribable<this, [peer: Peer]>
  • Event for when a new peer is connected via this transport.

    Returns Subscribable<this, [peer: Peer]>

    Subscribable that can be used to register listeners

started

  • get started(): boolean

transportOptions

Methods

Protected addPeer

  • addPeer(peer: Peer): void

start

stop

  • stop(): Promise<boolean>

Generated using TypeDoc