UNPKG

sinch-rtc

Version:

RTC JavaScript/Web SDK

52 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JsepMessage = void 0; const mxp_1 = require("../../mxp"); class JsepMessage { static mapType(sdp) { if (!sdp.type) return "candidate"; return sdp.type; } static mapPayload(type, sdp) { if (type == "candidate") { return JSON.stringify(sdp); } else return sdp.sdp; } static tryParse(message, onJsepMessage) { const sdp = message.getSdp(); const messages = new Array(); if (sdp) { const type = this.mapType(sdp); messages.push(new JsepMessage(type, this.mapPayload(type, sdp), message.from.instanceId)); } if (message.method == mxp_1.Method.Join) { messages.push(new JsepMessage("join", "", message.from.instanceId)); } if (messages.length == 0) return false; onJsepMessage(messages); return true; } constructor(type, data, instanceId) { this.type = type; this.data = data; this.instanceId = instanceId; } get isOffer() { return "offer" == this.type; } get isAnswer() { return "answer" == this.type; } get isCandidate() { return "candidate" == this.type; } get isJoin() { return "join" == this.type; } } exports.JsepMessage = JsepMessage; //# sourceMappingURL=JsepMessage.js.map