1.1.1 • Published 3 years ago

@webp2p/adapters v1.1.1

Weekly downloads
-
License
GPLv3
Repository
github
Last release
3 years ago

adapters

import { Signaling, SignalMessage } from '@webp2p/ports';
import { io, Socket } from 'socket.io-client';

export class SignalingImpl implements Signaling<Socket> {
  conn: Socket;

  constructor(readonly signalingServer: string) {
    this.conn = io(signalingServer);
  }

  on(event: string, fn: (message: SignalMessage) => void) {
    this.conn.on(event, fn);
  }

  emit<T>(event: string, message: T) {
    this.conn.emit(event, message);
  }
}

This library was generated with Nx.

Running unit tests

Run nx test adapters to execute the unit tests via Jest.