sinch-rtc
Version:
RTC JavaScript/Web SDK
47 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Body = void 0;
const Message_1 = require("../Message");
/**
* Represents payload of MXP message
*/
class Body {
constructor(type, data) {
this.type = type;
this.data = data;
}
isMedia() {
return this.type === Body.mediaType;
}
isSdp() {
return this.type === Body.sdpType && this.data != undefined;
}
isClientEvent() {
return this.type === Body.clientEventType && this.data != undefined;
}
isError() {
return this.type === Body.errorJsonType && this.data != undefined;
}
static sdp(data) {
return new Body(this.sdpType, data);
}
static client(data) {
return new Body(this.clientType, data);
}
static media(data) {
return new Body(this.mediaType, data);
}
static clientEvent(event) {
return new Body(this.clientEventType, JSON.stringify({ name: event }));
}
static error(error) {
return new Body(this.errorJsonType, Message_1.Message.errorToJsonString(error));
}
}
exports.Body = Body;
Body.clientType = "client";
Body.sdpType = "sdp";
Body.mediaType = "media";
Body.clientEventType = "clientEvent";
Body.errorJsonType = "error/json";
//# sourceMappingURL=Body.js.map