UNPKG

simple-peer-wrapper

Version:

A wrapper for simple-peer that includes a socket.io signaling server client. To be used in the browser with simple-peer-server.

31 lines (23 loc) 598 B
const SocketIOClientWrapper = require('./socket-io-client-wrapper.js'); class SimplePeerWrapper { constructor(options) { this.socketClient = new SocketIOClientWrapper(options); this.peerClient = this.socketClient.peerClient; } connect() { this.peerClient.init(); } isConnectionStarted() { return this.peerClient.isPeerStarted(); } send(data) { this.peerClient.sendData(data); } on(event, callback) { this.peerClient.setEventCallback(event, callback); } close() { this.peerClient.terminateSession(); } } module.exports = SimplePeerWrapper;