vani-meeting-client
Version:
Vani Meeting Clinet SDK
558 lines (557 loc) • 30 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, MessagePayload, LogLevel } from "..";
import { Participant } from "../model/Participant";
import * as log from 'loglevel';
import { Track, TrackKind } from "../model/Track";
import { SFUMessageType, WebSocketBasicEvents } from "../websocket-handler/WebsocketHandler";
import { VaniEventListener } from "../utility/VaniEventListener";
import { Utility } from "../utility/Utility";
var CommunicationHandler = /** @class */ (function () {
function CommunicationHandler(meetingHandler) {
var _this = this;
this.isStartAndSetupWithServerCalled = false;
this.eventEmitter = new VaniEventListener();
this.allParticipants = [];
this.selfTracks = [];
this.allTracks = [];
this.isReachable = true;
this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.restartTransport();
return [2 /*return*/];
});
}); };
this.requestToCloseTheRoom = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(WebSocketBasicEvents.CloseRoomForceFully, {});
return [2 /*return*/];
});
}); };
//Connection Recheck
this.destoryRoomForcefully = function () {
var _a;
(_a = _this.meetingHandler) === null || _a === void 0 ? void 0 : _a.endAndDestory();
};
this.checkIfInternetReachable = function (count) {
var _a;
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("checkIfInternetReachable pre", _this.meetingStartRequest);
if (!_this.meetingStartRequest) {
(_a = _this.meetingHandler) === null || _a === void 0 ? void 0 : _a.endAndDestory();
return;
}
if (count === 2) {
_this.emitMessageToSource(VaniEvent.OnNotReachable, {});
}
_this.isReachable = false;
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("checkIfInternetReachable");
fetch(_this.meetingStartRequest.urlToCheckInternetPresent, {
method: 'GET',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
}
}).then(function (response) { return response.text(); })
.then(function (data) { return _this.onApiResponded(count); })
.catch(function (error) {
var _a;
count = count + 1;
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.error('Error:', error);
if (_this.meetingStartRequest) {
if (_this.meetingStartRequest.shouldKeepTryToReconnect === false && count > 35) {
_this.emitMessageToSource(VaniEvent.OnReconectionTimeout, {});
(_a = _this.meetingHandler) === null || _a === void 0 ? void 0 : _a.endAndDestory();
return;
}
_this.internetReachbilityTimeout = window.setTimeout(_this.checkIfInternetReachable, 2000, count);
}
});
;
};
this.restartSFU = function () { return __awaiter(_this, void 0, void 0, function () {
var messageJson;
var _a;
return __generator(this, function (_b) {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.cleanup(false);
messageJson = { to: "self", type: SFUMessageType.ReloadSFU, message: SFUMessageType.ReloadSFU };
this.sendWebSocketMessage(SFUMessageType.SFUMessage, messageJson);
return [2 /*return*/];
});
}); };
this.reloadSFUCleanUpDone = function () { return __awaiter(_this, void 0, void 0, function () {
var videoCallHandler;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this.videoCallHandler = undefined;
this.allTracks = this.allTracks.filter(function (eachTrack) { return eachTrack.isLocalTrack === true; });
return [4 /*yield*/, ((_a = this.meetingHandler) === null || _a === void 0 ? void 0 : _a.recreateVideoCallHandler())];
case 1:
videoCallHandler = _b.sent();
if (videoCallHandler) {
this.setVideoCallHandler(videoCallHandler);
videoCallHandler.init();
}
return [2 /*return*/];
}
});
}); };
this.meetingHandler = meetingHandler;
this.eventEmitter.setMaxListeners(100000);
}
CommunicationHandler.prototype.setMeetingStartRequest = function (_meetingStartRequest) {
this.meetingStartRequest = _meetingStartRequest;
};
CommunicationHandler.prototype.setWebsocketCallHandler = function (_websocketCallHandler) {
this.websocketCallHandler = _websocketCallHandler;
};
CommunicationHandler.prototype.setVideoCallHandler = function (_videoCallHandler) {
this.videoCallHandler = _videoCallHandler;
};
CommunicationHandler.prototype.isReady = function () {
return this.meetingStartRequest !== undefined;
};
CommunicationHandler.prototype.emitMessageToSource = function (emitType, payload) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.eventEmitter.emit(emitType, payload);
return [2 /*return*/];
});
});
};
CommunicationHandler.prototype.getEventEmitter = function () {
return this.eventEmitter;
};
CommunicationHandler.prototype.onAudioVideoStatusUpdated = function (data) {
if (data.message && data.message.participant && data.message.participant.userId) {
var participant = this.participantByUserId(data.message.participant.userId);
if (participant) {
participant.isVideoEnable = data.message.participant.isVideoEnable;
participant.isAudioEnable = data.message.participant.isAudioEnable;
this.emitMessageToSource(VaniEvent.OnAudioVideoStatusUpdated, participant);
}
}
};
CommunicationHandler.prototype.getSelfParticipant = function () {
var _a;
if (this.meetingStartRequest) {
var participant = this.participantByUserId((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId);
if (!participant) {
participant = new Participant(this.meetingStartRequest.userId, this.meetingStartRequest.roomId, this.meetingStartRequest.userData, this.meetingStartRequest.isAdmin);
participant.isWhiteboardBlockedByAdmin = !this.meetingStartRequest.defaultWhiteboardEditEnable;
participant.isAudioBlockedByAdmin = this.meetingStartRequest.defaultAudioBlocked;
participant.isVideoBlockedByAdmin = this.meetingStartRequest.defaultVideoBlocked;
participant.isScreenshareBlockedByAdmin = this.meetingStartRequest.defaultScreenShareBlocked;
participant.isRecordingUser = this.meetingStartRequest.isRecordingUser;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist from getSelfParticipant", participant);
this.addParticipantIfNotExist(participant);
}
return participant;
}
return undefined;
};
CommunicationHandler.prototype.downloadParticipantsData = function () {
var _a;
var obj = { type: WebSocketBasicEvents.GetAllParticipant, message: "" };
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(WebSocketBasicEvents.GetAllParticipant, obj);
};
CommunicationHandler.prototype.onServerParticipants = function (data) {
var _this = this;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
if (data && data.message) {
var userIds = "";
Object.entries(data.message).forEach(function (_a) {
var userId = _a[0], participant = _a[1];
userIds = userIds + " " + userId;
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist from onServerParticipants", data);
_this.addParticipantIfNotExist(participant, false);
});
// const allParticiapntsToBeRemove = this.allParticipants.filter(participant => (userIds.includes(participant.userId) === false))
// allParticiapntsToBeRemove.forEach(participant => {
// this.removeParticipant(participant, true);
// })
this.emitMessageToSource(VaniEvent.OnAllParticipants, this.allParticipants);
}
};
CommunicationHandler.prototype.getAllParticipants = function () {
return this.allParticipants;
};
CommunicationHandler.prototype.participantByUserId = function (userId) {
return this.allParticipants.find(function (participant) { return participant.userId === userId; });
};
CommunicationHandler.prototype.addParticipantIfNotExist = function (participant, shouldInfrom) {
var _a, _b, _c;
if (shouldInfrom === void 0) { shouldInfrom = false; }
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist", this.allParticipants);
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist new user", participant);
var oldParticipant = this.participantByUserId(participant.userId);
if (oldParticipant) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Old participant", oldParticipant);
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("new participant", participant);
oldParticipant = Object.assign(oldParticipant, participant);
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Old participant after update", oldParticipant);
if (shouldInfrom) {
this.emitMessageToSource(VaniEvent.OnParticipantDataUpdated, oldParticipant);
}
this.updateParticipantAudioVideoDataAccordingToTrack(oldParticipant);
try {
if (oldParticipant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
this.meetingStartRequest.userData = oldParticipant.userData;
}
}
catch (err) {
}
return oldParticipant;
}
else {
participant = Object.assign(new Participant(participant.userId, participant.roomId, participant.userData, participant.isAdmin), participant);
this.updateParticipantAudioVideoDataAccordingToTrack(participant);
try {
if (participant.userId === ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId)) {
this.meetingStartRequest.userData = participant.userData;
}
}
catch (err) {
}
this.allParticipants.push(participant);
if (shouldInfrom) {
this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
}
(_c = this.videoCallHandler) === null || _c === void 0 ? void 0 : _c.onParticipantUpdated();
return participant;
}
};
CommunicationHandler.prototype.removeParticipant = function (participant, shouldInfrom) {
var _this = this;
var _a;
if (shouldInfrom === void 0) { shouldInfrom = false; }
var tracks = this.getAllTracksForParticipant(participant);
if (tracks) {
tracks.forEach(function (track) {
_this.removeTrack(track, shouldInfrom);
});
}
Utility.deleteArrayObject(participant, this.allParticipants);
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantUpdated();
if (shouldInfrom) {
this.emitMessageToSource(VaniEvent.OnUserLeft, participant);
}
};
CommunicationHandler.prototype.onUserLeft = function (data) {
if (data && data.message && data.message.participant && data.message.participant.userId) {
var participant = this.participantByUserId(data.message.participant.userId);
if (participant) {
this.removeParticipant(participant, true);
}
}
};
CommunicationHandler.prototype.updateParticipantAudioVideoDataAccordingToTrack = function (participant) {
participant.isAudioEnable = this.getAllTracks().find(function (track) { return (track.trackKind === TrackKind.Audio && track.participant.userId === participant.userId); }) ? true : false;
participant.isVideoEnable = this.getAllTracks().find(function (track) { return (track.trackKind === TrackKind.Video && track.participant.userId === participant.userId); }) ? true : false;
};
CommunicationHandler.prototype.getSelfTrackByType = function (trackKind) {
return this.selfTracks.find(function (track) { return track.trackKind === trackKind; });
};
CommunicationHandler.prototype.getAllSelfTracks = function () {
return this.selfTracks;
};
CommunicationHandler.prototype.getAllTracks = function () {
return this.allTracks;
};
CommunicationHandler.prototype.getTrackById = function (trackId) {
return this.allTracks.find(function (track) { return track.trackId === trackId; });
};
CommunicationHandler.prototype.getLocalTrackById = function (trackId) {
return this.selfTracks.find(function (track) { return track.trackId === trackId; });
};
CommunicationHandler.prototype.getAllTracksForParticipant = function (participant) {
return this.allTracks.filter(function (track) { var _a; return ((_a = track.participant) === null || _a === void 0 ? void 0 : _a.userId) === participant.userId; });
};
CommunicationHandler.prototype.removeTrack = function (track, shouldInfromVideoController) {
var _a;
if (shouldInfromVideoController === void 0) { shouldInfromVideoController = true; }
if (track.trackKind === TrackKind.Audio) {
track.participant.isAudioEnable = false;
}
else if (track.trackKind === TrackKind.Video) {
track.participant.isVideoEnable = false;
}
if (shouldInfromVideoController && this.isStartAndSetupWithServerCalled && track.isLocalTrack) {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.stopTrack(track);
}
Utility.deleteArrayObject(track, this.allTracks);
Utility.deleteArrayObject(track, this.selfTracks);
this.emitMessageToSource(VaniEvent.OnTrackEnded, track);
if (track.track) {
track.track.stop();
}
try {
if (this.meetingStartRequest && this.meetingStartRequest.isMobileApp === true) {
if (track.track) {
track.track.release();
}
}
}
catch (err) {
}
};
CommunicationHandler.prototype.resumeProducerOrConsumerForTrack = function (track) {
var _a;
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.resumeProducerOrConsumerForTrack(track);
};
CommunicationHandler.prototype.pauseProducerOrConsumerForTrack = function (track) {
var _a;
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.pauseProducerOrConsumerForTrack(track);
};
CommunicationHandler.prototype.getConsumerForTrack = function (track) {
var _a;
return (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.getConsumerForTrack(track);
};
CommunicationHandler.prototype.addUpdateRemoteTrack = function (track, participant, shouldInfromIfNotExist) {
if (shouldInfromIfNotExist === void 0) { shouldInfromIfNotExist = false; }
var oldTrack = this.getTrackById(track.trackId);
if (oldTrack) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("oldtrack found");
track = Object.assign(oldTrack, track);
}
else {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("new track found");
track = Object.assign(new Track(participant, track.isLocalTrack, track.trackKind, track.track), track);
this.allTracks.push(track);
}
track.participant = participant;
if (track.trackKind === TrackKind.Audio) {
track.participant.isAudioEnable = true;
}
else if (track.trackKind === TrackKind.Video) {
track.participant.isVideoEnable = true;
}
if (shouldInfromIfNotExist) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("emitMessageToSource");
this.emitMessageToSource(VaniEvent.OnTrack, track);
}
return track;
};
CommunicationHandler.prototype.addUpdateLocalTrack = function (track) {
var _this = this;
var _a;
var oldTrack = this.getLocalTrackById(track.trackId);
if (oldTrack) {
oldTrack.updateTrackWithNewData(track);
track = oldTrack;
}
else {
track.track.onended = function (ev) {
_this.removeTrack(track);
};
this.allTracks.push(track);
this.selfTracks.push(track);
}
if (track.trackKind === TrackKind.Audio) {
track.participant.isAudioEnable = true;
}
else if (track.trackKind === TrackKind.Video) {
track.participant.isVideoEnable = true;
}
if (this.isStartAndSetupWithServerCalled) {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.sendTrack(track);
}
this.emitMessageToSource(VaniEvent.OnTrack, track);
};
CommunicationHandler.prototype.onOldMessages = function (data) {
var _this = this;
var oldMessages = [];
if (data && data.messages && data.messages.length > 0) {
data.messages.forEach(function (messageDict) {
if (messageDict.message) {
oldMessages.push(_this.onMessage(messageDict.message, false));
}
});
}
else if (data && data.message && data.message.length > 0) {
data.message.forEach(function (messageDict) {
if (messageDict.message) {
oldMessages.push(_this.onMessage(messageDict, false));
}
});
}
this.emitMessageToSource(VaniEvent.OnOldMessages, oldMessages);
};
CommunicationHandler.prototype.onMessage = function (message, shouldInfromSource) {
if (shouldInfromSource === void 0) { shouldInfromSource = true; }
var messagePayload = new MessagePayload(message.message, message.to);
messagePayload.extraData = message.extraData;
messagePayload.senderUserId = message.sender;
messagePayload.time = message.time;
messagePayload.type = message.type;
messagePayload.shouldPresist = message.shouldPresist;
if (messagePayload.senderUserId) {
messagePayload.sender = this.participantByUserId(messagePayload.senderUserId);
}
if (shouldInfromSource) {
this.emitMessageToSource(VaniEvent.OnNewChatMessageReceived, messagePayload);
}
return messagePayload;
};
CommunicationHandler.prototype.sendWebSocketMessage = function (type, data) {
var _a;
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(type, data);
};
CommunicationHandler.prototype.onVideoCallWebSocketMessage = function (websocketMessage) {
var _a;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
if (websocketMessage.type === SFUMessageType.ReloadSFUCleanUpDone) {
this.reloadSFUCleanUpDone();
}
else {
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onSocketMessage(websocketMessage);
}
return [2 /*return*/];
});
});
};
CommunicationHandler.prototype.onReconnect = function () {
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.onReconnect();
this.emitMessageToSource(VaniEvent.OnConnectionBack, {});
return [2 /*return*/];
});
});
};
CommunicationHandler.prototype.onStartMeeingCalled = function () {
var _a, _b, _c, _d;
if (this.isStartAndSetupWithServerCalled) {
return;
}
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onStartAndSetupWithServerCalled");
this.isStartAndSetupWithServerCalled = true;
var data = { user: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId };
var startMeetingCalled = { message: data, type: WebSocketBasicEvents.OnStartMeetingCalled, to: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.roomId };
(_c = this.websocketCallHandler) === null || _c === void 0 ? void 0 : _c.sendSocketMessage(WebSocketBasicEvents.OnStartMeetingCalled, startMeetingCalled);
var selfParticpant = this.getSelfParticipant();
if (selfParticpant) {
selfParticpant.isStartMeetingCalled = true;
}
(_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.init();
};
CommunicationHandler.prototype.onAudioBlocked = function (data) {
var _a, _b, _c;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
if (data.message.user) {
var participant = this.participantByUserId(data.message.user);
if (participant) {
participant.isAudioBlockedByAdmin = true;
if ((participant === null || participant === void 0 ? void 0 : participant.userId) === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
(_b = this.meetingHandler) === null || _b === void 0 ? void 0 : _b.muteUser((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId);
}
this.emitMessageToSource(VaniEvent.OnAudioBlocked, participant);
}
}
};
CommunicationHandler.prototype.onAudioUnblocked = function (data) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
if (data.message.user) {
var participant = this.participantByUserId(data.message.user);
if (participant) {
participant.isAudioBlockedByAdmin = false;
this.emitMessageToSource(VaniEvent.OnAudioUnblocked, participant);
}
}
};
CommunicationHandler.prototype.onVideoBlocked = function (data) {
var _a, _b, _c;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
if (data.message.user) {
var participant = this.participantByUserId(data.message.user);
if (participant) {
participant.isVideoBlockedByAdmin = true;
if ((participant === null || participant === void 0 ? void 0 : participant.userId) === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
(_b = this.meetingHandler) === null || _b === void 0 ? void 0 : _b.pauseCamera((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId);
}
this.emitMessageToSource(VaniEvent.OnVideoBlocked, participant);
}
}
};
CommunicationHandler.prototype.onVideoUnblocked = function (data) {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
if (data.message.user) {
var participant = this.participantByUserId(data.message.user);
if (participant) {
participant.isVideoBlockedByAdmin = false;
this.emitMessageToSource(VaniEvent.OnVideoUnblocked, participant);
}
}
};
CommunicationHandler.prototype.onIceCandidateDisconnected = function () {
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onIceCandidateDisconnected", this.internetReachbilityTimeout);
if (this.internetReachbilityTimeout) {
return;
}
this.internetReachbilityTimeout = window.setTimeout(this.checkIfInternetReachable, 200, 0);
};
CommunicationHandler.prototype.onApiResponded = function (count) {
var _a;
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onApiResponded", count);
if (this.isReachable === false) {
this.isReachable = true;
this.internetReachbilityTimeout = undefined;
// if (count < 2 && this.websocketCallHandler?.isWebScoketConnected()) {
// this.videoCallHandler?.reconnectedWithoutPing()
// }
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.reconnectedWithoutPing();
}
};
CommunicationHandler.prototype.cleanup = function () {
var _this = this;
this.selfTracks.forEach(function (eachTrack) {
_this.removeTrack(eachTrack, false);
});
this.eventEmitter.removeAllListeners();
this.videoCallHandler = undefined;
this.meetingStartRequest = undefined;
this.websocketCallHandler = undefined;
this.meetingHandler = undefined;
};
return CommunicationHandler;
}());
export { CommunicationHandler };