Skip to content
Snippets Groups Projects
Connection.js 735 B
Newer Older
export default class AbstractConnection extends EventTarget {
  constructor(options) {
    super()

    this.options = options
  }

  /*
    Supported events:
     - roomJoined => ()
     - roomLeft => ()
     - channelOpened => ({detail: uid})
     - channelError => ({detail: uid})
     - channelClosed => ({detail: uid})
     - messageReceived => ({detail: {uid, channel, message}})
    */

  getUserID() {
    // => int
  }

  getPeerHandle(/*uid*/) {
    // => opaque
  }

  getPeerFootprint(/*uid*/) {
    // => Promise => int
  }

  send(/*uid, channel, message*/) {
    // => void
  }

  broadcast(/*channel, message*/) {
    // => void
  }

  terminatePeer(/*uid*/) {
    // => void
  }

  destructor() {
    // => void
  }
}