Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 629 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 629 Bytes

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.