Home Reference Source

lib/messages/mresponse.js

'use strict'

/**
 * The message containing the response to create a WebRTC connexion
 */
class MResponse {
  /**
     * @param {string} temporaryId A temporary identifier during the socket
     * creation. The key will be changed to peerId when the connexion is established
     * successfully.
     * @param {string} peerId The identifier of the peer that will be reachable
     * through the socket being created. Null if it is yet to be known.
     * @param {object} offer The WebRTC offer containing ways to establish a direct
     * peer-to-peer connexions. See WebRTC for more information.
     */
  constructor (temporaryId, peerId, offer, offerType = 'init') {
    this.tid = temporaryId
    this.peer = peerId
    this.offer = offer
    this.type = 'MResponse'
    this.offerType = offerType
  }
}

module.exports = MResponse