sinch-rtc
Version:
RTC JavaScript/Web SDK
95 lines • 4.32 kB
JavaScript
"use strict";
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CallClientFactory = exports.DefaultCallClient = void 0;
const CallClientInstance_1 = require("./CallClientInstance");
const WebRTCStatsCollector_1 = require("./reporting/WebRTCStatsCollector");
const CallClientEventFanout_1 = require("./listeners/CallClientEventFanout");
class DefaultCallClient {
constructor(userId, applicationKey, mediaManager) {
this.userId = userId;
this.applicationKey = applicationKey;
this.mediaManager = mediaManager;
this.pendingEventListeners = new Array();
}
getCall(callId) {
return this.callclient.getCall(callId);
}
init(callInitiator, rtcProfile, rtcConfiguration, fetchIceServers, callReporter, pushSender, useRelayIceCandidatesOnly, features, instanceId, callerIdentifier) {
this.instance = new CallClientInstance_1.CallClientInstance(this.userId, this.applicationKey, rtcConfiguration, fetchIceServers, callInitiator, rtcProfile, new CallClientEventFanout_1.CallClientEventFanout(this), pushSender, callReporter, new WebRTCStatsCollector_1.WebRTCStatsCollector(), this.mediaManager, useRelayIceCandidatesOnly, features, instanceId, callerIdentifier);
this.pendingEventListeners.forEach(this.instance.addListener);
this.pendingEventListeners = [];
}
get callclient() {
if (this.instance)
return this.instance;
else
throw new Error("Invalid operation");
}
handleCallPushPayload(notificationResult) {
if (!notificationResult.callNotificationResult.hasTimedOut()) {
this.callclient.handleCallPushPayload(notificationResult);
}
}
callUser(toUserId, headers) {
return __awaiter(this, void 0, void 0, function* () {
return this.callclient.callUser(toUserId, false, headers);
});
}
callUserVideo(toUserId, headers) {
return __awaiter(this, void 0, void 0, function* () {
return this.callclient.callUser(toUserId, true, headers);
});
}
callPhoneNumber(toUserId, headers) {
return __awaiter(this, void 0, void 0, function* () {
return this.callclient.callPhoneNumber(toUserId, headers);
});
}
callSip(toUserId, headers) {
return __awaiter(this, void 0, void 0, function* () {
return this.callclient.callSip(toUserId, false, headers);
});
}
callConference(toUserId, headers) {
return __awaiter(this, void 0, void 0, function* () {
return this.callclient.callConference(toUserId, false, headers);
});
}
addListener(listener) {
var _a;
if (!this.instance)
this.pendingEventListeners.push(listener);
else
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.addListener(listener);
}
removeListener(listener) {
var _a;
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.removeEventListener(listener);
}
setAudioTrackConstraints(constraints) {
this.callclient.audioConstraints = constraints;
}
setVideoTrackConstraints(constraints) {
this.callclient.videoConstraints = constraints;
}
getInstance() {
return this.instance;
}
}
exports.DefaultCallClient = DefaultCallClient;
class CallClientFactory {
static create(userId, applicationKey, mediaManager) {
return new DefaultCallClient(userId, applicationKey, mediaManager);
}
}
exports.CallClientFactory = CallClientFactory;
//# sourceMappingURL=DefaultCallClient.js.map