vani-meeting-client
Version:
Vani Meeting Clinet SDK
626 lines (625 loc) • 32.5 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { VaniEvent, MeetingStartRequest, ChatSendVia, MeetingType, LogLevel } from ".";
import { DynamicLibHelper } from "./utility/DynamicLibHelper";
import * as log from 'loglevel';
import { SFUMessageType, WebSocketBasicEvents, WebsocketHandler } from "./websocket-handler/WebsocketHandler";
import { CommunicationHandler } from "./inter-communication-handler/CommunicationHandler";
import { UserMediaHandler } from "./user-media-handler/UserMediaHandler";
// import Analytics from 'analytics'
// import googleAnalytics from '@analytics/google-analytics'
var MeetingHandler = /** @class */ (function () {
function MeetingHandler() {
var _this = this;
this.communicationHandler = new CommunicationHandler(this);
this.cleanupWebsocket = function () {
var _a;
try {
(_a = _this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
_this.websocketCallHandler = undefined;
}
catch (err) {
}
};
this.isWebSocketInPreConnect = function () {
var _a;
if (_this.websocketCallHandler) {
return (_a = _this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.isWebSocketInPreConnect();
}
return false;
};
this.requestToCloseTheRoom = function () {
var _a;
(_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.requestToCloseTheRoom();
};
this.preconnect = function (url) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!this.websocketCallHandler) {
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
}
this.websocketCallHandler.startSocketConnection(true, url);
return [2 /*return*/];
});
}); };
this.recreateVideoCallHandler = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/];
}
this.videoCallHandler = undefined;
_a = this;
return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.meetingType, this.meetingStartRequest, this.communicationHandler)];
case 1:
_a.videoCallHandler = _c.sent();
return [2 /*return*/, this.videoCallHandler];
}
});
}); };
this.getClientStats = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ((_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.getClientStats())];
case 1: return [2 /*return*/, _b.sent()];
}
});
}); };
this.refetchTrackForParticipant = function (participant) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.refetchTrackForParticipant(participant);
return [2 /*return*/];
});
}); };
this.isStartMeetingCalled = function () {
var _a;
return (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.isStartAndSetupWithServerCalled;
};
this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.restartTransport();
return [2 /*return*/];
});
}); };
this.restartSFU = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ((_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.restartSFU())];
case 1:
_b.sent();
return [2 /*return*/];
}
});
}); };
}
MeetingHandler.prototype.meetingStartRequestObject = function (roomId, userId, appId, wssUrl, shouldIgnoreCaseForRoomId) {
if (shouldIgnoreCaseForRoomId === void 0) { shouldIgnoreCaseForRoomId = false; }
if (!this.meetingStartRequest) {
if (roomId === userId) {
roomId = roomId + "-r";
}
this.meetingStartRequest = new MeetingStartRequest(roomId, userId, appId, wssUrl, shouldIgnoreCaseForRoomId);
}
return this.meetingStartRequest;
};
MeetingHandler.prototype.endAndDestory = function () {
this.cleanup();
};
MeetingHandler.prototype.init = function () {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function () {
var _d, _e;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/, false];
}
log.setLevel("trace");
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.setMeetingStartRequest(this.meetingStartRequest);
if (!(((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp) && !this.reactNativeWebrtcPlugin)) return [3 /*break*/, 2];
_d = this;
return [4 /*yield*/, new DynamicLibHelper().getReactNativeWebrtcPlugin(this.meetingStartRequest)];
case 1:
_d.reactNativeWebrtcPlugin = _f.sent();
this.reactNativeWebrtcPlugin.registerGlobals();
_f.label = 2;
case 2:
if (!!this.videoCallHandler) return [3 /*break*/, 4];
_e = this;
return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.meetingType, this.meetingStartRequest, this.communicationHandler)];
case 3:
_e.videoCallHandler = _f.sent();
return [3 /*break*/, 5];
case 4:
if (this.meetingStartRequest) {
this.videoCallHandler.setMeetingRequest(this.meetingStartRequest);
}
_f.label = 5;
case 5:
if (!this.websocketCallHandler) {
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
}
else if (this.meetingStartRequest) {
this.websocketCallHandler.setMeetingRequest(this.meetingStartRequest);
}
// this.handleGA();
this.emitMessageToSource(VaniEvent.OnInitDone, {});
return [2 /*return*/, true];
}
});
});
};
MeetingHandler.prototype.switchCamera = function () {
var _a;
(_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.switchCamera();
};
MeetingHandler.prototype.startLocalStream = function (isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload) {
var _a, _b;
if (shouldAddTrackImmediately === void 0) { shouldAddTrackImmediately = true; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/, false];
}
if ((((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.isMobileApp) && !this.reactNativeWebrtcPlugin) || ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isReady()) === false) {
log.error("Init method not called");
return [2 /*return*/];
}
if (!this.userMediaHandler) {
this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
}
if (isVideoRequired === false && isAudioRequired === false) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream return");
return [2 /*return*/];
}
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("startLocalStream starting");
return [4 /*yield*/, this.userMediaHandler.startLocalStream(isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload)];
case 1:
_c.sent();
return [2 /*return*/, true];
}
});
});
};
MeetingHandler.prototype.startScreenShare = function (isAudioRequired, shouldAddTrackImmediately, screensharePayload) {
var _a, _b;
if (isAudioRequired === void 0) { isAudioRequired = false; }
if (shouldAddTrackImmediately === void 0) { shouldAddTrackImmediately = true; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_c) {
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/];
}
if ((((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.isMobileApp) && !this.reactNativeWebrtcPlugin) || ((_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.isReady()) === false) {
log.error("Init method not called");
return [2 /*return*/];
}
if (!this.userMediaHandler) {
this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
}
this.userMediaHandler.startScreenShare(isAudioRequired, shouldAddTrackImmediately, screensharePayload);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.stopScreenSharing = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (this.userMediaHandler) {
this.userMediaHandler.stopScreenSharing();
}
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.getDevices = function (deviceType) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.getDevice(deviceType)];
});
});
};
MeetingHandler.prototype.pauseCamera = function (userId) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_b) {
if (this.userMediaHandler) {
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.pauseCamera(userId)];
}
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
return [2 /*return*/];
});
}); })];
});
});
};
MeetingHandler.prototype.muteUser = function (userId) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_b) {
if (this.userMediaHandler) {
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.muteUser(userId)];
}
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
return [2 /*return*/];
});
}); })];
});
});
};
MeetingHandler.prototype.resumeCamera = function (userId) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_b) {
if (this.userMediaHandler) {
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.resumeCamera(userId)];
}
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
return [2 /*return*/];
});
}); })];
});
});
};
MeetingHandler.prototype.unmute = function (userId) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_b) {
if (this.userMediaHandler) {
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.unmute(userId)];
}
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
return [2 /*return*/];
});
}); })];
});
});
};
MeetingHandler.prototype.resumeStreamWithoutAdding = function (streamKind) {
var _a;
return (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.resumeStreamWithoutAdding(streamKind);
};
MeetingHandler.prototype.pauseStreamWithoutStopping = function (streamKind) {
var _a;
return (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.pauseStreamWithoutStopping(streamKind);
};
MeetingHandler.prototype.stopTrack = function (track) {
var _a;
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.removeTrack(track);
};
MeetingHandler.prototype.addCustomTrack = function (track) {
var _a;
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.addUpdateLocalTrack(track);
};
MeetingHandler.prototype.pauseIncomingTrack = function (track) {
var _a;
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.pauseIncomingTrack(track);
};
MeetingHandler.prototype.resumeIncomingTrack = function (track) {
var _a;
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.resumeIncomingTrack(track);
};
MeetingHandler.prototype.updateSpatialForTrack = function (track, spatialLayerIndex) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.updateSpatialForTrack(track, spatialLayerIndex);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.resumeProducerOrConsumerForTrack = function (track) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.resumeProducerOrConsumerForTrack(track);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.pauseProducerOrConsumerForTrack = function (track) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.pauseProducerOrConsumerForTrack(track);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.getConsumerForTrack = function (track) {
var _a;
return (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getConsumerForTrack(track);
};
//Participant
MeetingHandler.prototype.participantByUserId = function (userId) {
var _a, _b, _c;
if (this.meetingStartRequest) {
if (userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
return (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getSelfParticipant();
}
return (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.participantByUserId(userId);
}
return undefined;
};
MeetingHandler.prototype.updateParticipantData = function (participant) {
var _a, _b;
if (this.meetingStartRequest && participant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
this.meetingStartRequest.userData = participant.userData;
}
var oldParticipant = this.participantByUserId(participant.userId);
if (oldParticipant) {
oldParticipant = Object.assign(oldParticipant, participant);
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("updateParticipantData", oldParticipant);
(_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.UpdateParticipant, oldParticipant);
}
return oldParticipant;
};
MeetingHandler.prototype.updateParticipantUserData = function (participant) {
var _a, _b;
if (this.meetingStartRequest && participant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
this.meetingStartRequest.userData = participant.userData;
}
var oldParticipant = this.participantByUserId(participant.userId);
if (oldParticipant) {
oldParticipant.userData = participant.userData;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("updateParticipantUserData", oldParticipant);
(_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.UpdateParticipantData, oldParticipant);
}
return oldParticipant;
};
MeetingHandler.prototype.getUpdatedParticipantsListFromServer = function () {
var _a;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("getUpdatedParticipantsListFromServer", this.communicationHandler);
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
};
MeetingHandler.prototype.getAllParticipants = function () {
if (this.communicationHandler) {
return this.communicationHandler.getAllParticipants();
}
else {
return [];
}
};
MeetingHandler.prototype.getAllTracks = function () {
if (this.communicationHandler) {
return this.communicationHandler.getAllTracks();
}
else {
return [];
}
};
MeetingHandler.prototype.getTracksByParticipantId = function (participantId) {
var participant = this.participantByUserId(participantId);
if (participant) {
if (this.communicationHandler) {
return this.communicationHandler.getAllTracksForParticipant(participant);
}
}
return [];
};
MeetingHandler.prototype.isWebScoketConnected = function () {
var _a;
if (this.websocketCallHandler) {
return (_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected();
}
return false;
};
///Messages
MeetingHandler.prototype.sendMessage = function (message) {
var _a, _b, _c;
if (!message.sender) {
message.sender = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
}
if (!message.sender || !this.meetingStartRequest) {
return { message: "Invalid Meeting Request", error: 'InvalidMeetingRequest', isSuccess: false };
}
message.senderUserId = message.sender.userId;
if (message.sender.isMessageBlockedByAdmin) {
return { message: "Blocked By Admin", error: 'BlockedByAdmin', isSuccess: false };
}
else {
var to = message.to === "all" ? this.meetingStartRequest.roomId : message.to;
var messageObj = { type: "chat", message: message.toJsonObjectForSending(), to: to, shouldPresist: message.shouldPresist };
if (message.chatSendVia === ChatSendVia.DataChannel) {
(_b = this.videoCallHandler) === null || _b === void 0 ? void 0 : _b.sendMessageViaDataChannel(messageObj);
}
else {
(_c = this.websocketCallHandler) === null || _c === void 0 ? void 0 : _c.sendSocketMessage(WebSocketBasicEvents.Message, messageObj);
}
return { message: "Message Sent", error: 'NoError', isSuccess: true };
}
};
MeetingHandler.prototype.getOldMessages = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("getOldMessages");
if (this.websocketCallHandler) {
this.websocketCallHandler.sendSocketMessage(WebSocketBasicEvents.GetOldMessages, {});
}
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.onOldMessages = function (data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.checkSocket = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/, false];
}
if (!this.websocketCallHandler) {
log.error("Init method not called");
return [2 /*return*/, false];
}
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("checkSocket");
this.websocketCallHandler.startSocketConnection();
return [2 /*return*/, true];
});
});
};
MeetingHandler.prototype.startMeeting = function () {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.onStartMeeingCalled();
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.getMeetingStartTime = function () {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var meetingStartTimeObject;
return __generator(this, function (_c) {
if (!this.meetingStartRequest) {
log.error("meetingStartRequestObject not found");
return [2 /*return*/, false];
}
if (!this.websocketCallHandler) {
log.error("Init method not called");
return [2 /*return*/, false];
}
meetingStartTimeObject = { type: WebSocketBasicEvents.GetMeetingStartTime, to: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId };
(_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.GetMeetingStartTime, meetingStartTimeObject);
return [2 /*return*/, true];
});
});
};
MeetingHandler.prototype.startRTMPStream = function (urls) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var messageJson;
return __generator(this, function (_c) {
if (((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.meetingType) === MeetingType.SFU) {
messageJson = { to: "self", type: SFUMessageType.OnStartRTMP, message: { urls: urls } };
(_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.sendWebSocketMessage(SFUMessageType.SFUMessage, messageJson);
}
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.getEventEmitter = function () {
var _a;
return (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getEventEmitter();
};
MeetingHandler.prototype.emitMessageToSource = function (emitType, payload) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(emitType, payload);
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.cleanup = function () {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_e) {
this.meetingStartRequest = undefined;
this.reactNativeWebrtcPlugin = undefined;
try {
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
this.communicationHandler = undefined;
}
catch (err) {
}
try {
(_b = this.videoCallHandler) === null || _b === void 0 ? void 0 : _b.cleanup();
this.videoCallHandler = undefined;
}
catch (err) {
}
try {
(_c = this.websocketCallHandler) === null || _c === void 0 ? void 0 : _c.cleanup();
this.websocketCallHandler = undefined;
}
catch (err) {
}
try {
(_d = this.userMediaHandler) === null || _d === void 0 ? void 0 : _d.cleanup();
this.userMediaHandler = undefined;
}
catch (err) {
}
return [2 /*return*/];
});
});
};
MeetingHandler.prototype.handleGA = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/];
});
});
};
return MeetingHandler;
}());
export { MeetingHandler };