vani-meeting-client 0.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/lib/MeetingHandler.d.ts +45 -0
- package/lib/MeetingHandler.js +410 -0
- package/lib/base/Base.d.ts +9 -0
- package/lib/base/Base.js +18 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/inter-communication-handler/CommunicationHandler.d.ts +54 -0
- package/lib/inter-communication-handler/CommunicationHandler.js +363 -0
- package/lib/model/AudioVideoPauseResumeResponse.d.ts +5 -0
- package/lib/model/AudioVideoPauseResumeResponse.js +1 -0
- package/lib/model/Event.d.ts +63 -0
- package/lib/model/Event.js +26 -0
- package/lib/model/MeetingStartRequest.d.ts +40 -0
- package/lib/model/MeetingStartRequest.js +44 -0
- package/lib/model/MessagePayload.d.ts +27 -0
- package/lib/model/MessagePayload.js +25 -0
- package/lib/model/Participant.d.ts +16 -0
- package/lib/model/Participant.js +22 -0
- package/lib/model/TaskResponse.d.ts +5 -0
- package/lib/model/TaskResponse.js +1 -0
- package/lib/model/Track.d.ts +18 -0
- package/lib/model/Track.js +26 -0
- package/lib/user-media-handler/UserMediaHandler.d.ts +32 -0
- package/lib/user-media-handler/UserMediaHandler.js +654 -0
- package/lib/utility/DynamicLibHelper.d.ts +8 -0
- package/lib/utility/DynamicLibHelper.js +107 -0
- package/lib/utility/Utility.d.ts +3 -0
- package/lib/utility/Utility.js +12 -0
- package/lib/utility/VaniEventListener.d.ts +4 -0
- package/lib/utility/VaniEventListener.js +24 -0
- package/lib/video-call-handler/BaseVideoCallHandler.d.ts +19 -0
- package/lib/video-call-handler/BaseVideoCallHandler.js +35 -0
- package/lib/video-call-handler/SFUHandler.d.ts +38 -0
- package/lib/video-call-handler/SFUHandler.js +432 -0
- package/lib/video-call-handler/WebrtcHandler.d.ts +16 -0
- package/lib/video-call-handler/WebrtcHandler.js +96 -0
- package/lib/websocket-handler/WebsockerHandler.d.ts +22 -0
- package/lib/websocket-handler/WebsockerHandler.js +272 -0
- package/lib/websocket-handler/WebsocketHandler.d.ts +81 -0
- package/lib/websocket-handler/WebsocketHandler.js +402 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
|
|
2
|
+
# Vani Meeting SDK
|
|
3
|
+
Next generation video and audio API and SDK solutions to enhance your online experience. Engage with your audience in real-time, on any platform, from anywhere, through the addition of video and voice with Vani Meetings’s API and SDK solutions.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install vani-meeting.demo with npm
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install com.vanimeeting.demo
|
|
18
|
+
|
|
19
|
+
yarn add com.vanimeeting.demo
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage/Examples
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
import * as MeetingHandler from "com.vanimeeting.demo";
|
|
26
|
+
import * as EventEmitter from "events";
|
|
27
|
+
|
|
28
|
+
class WebrtcCallHandler {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.roomid = null;
|
|
31
|
+
this.meetingRequest = null;
|
|
32
|
+
this.evenetEmitter = new EventEmitter();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static instance = new WebrtcCallHandler();
|
|
36
|
+
static getInstance() {
|
|
37
|
+
if (WebrtcCallHandler.instance === null) {
|
|
38
|
+
WebrtcCallHandler.instance = new WebrtcCallHandler();
|
|
39
|
+
} else {
|
|
40
|
+
return WebrtcCallHandler.instance;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setup(roomid, userid, appName, userData) {
|
|
44
|
+
if (this.meetingRequest === null) {
|
|
45
|
+
const locaUserid =
|
|
46
|
+
new Date().getTime() + "_" + Math.floor(Math.random() * 20);
|
|
47
|
+
this.meetingRequest = MeetingHandler.meetingStartRequestObject(
|
|
48
|
+
roomid,
|
|
49
|
+
userid || locaUserid,
|
|
50
|
+
"demo" || appName
|
|
51
|
+
);
|
|
52
|
+
this.meetingRequest.numberOfUsers = 2;
|
|
53
|
+
this.meetingRequest.userData = userData;
|
|
54
|
+
}
|
|
55
|
+
return this.meetingRequest;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default WebrtcCallHandler;
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
First we have to import SDK.
|
|
64
|
+
```
|
|
65
|
+
import * as MeetingHandler from "com.vanimeeting.demo";
|
|
66
|
+
import * as EventEmitter from "events";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then we have to call meetingStartRequestObject which returns meetingStartRequestObject modal and accepts `roomId`, `userId`, `appId`, and `userData` as its params where:
|
|
70
|
+
|
|
71
|
+
* `roomId` : is always unique string to join a meeting.
|
|
72
|
+
* `userId` : is always unique string respective to user.
|
|
73
|
+
* `appId` : can be any manual id given by user.
|
|
74
|
+
* `userData` : any extra data.
|
|
75
|
+
```
|
|
76
|
+
setup(roomid, userid, appName, userData) {
|
|
77
|
+
if (this.meetingRequest === null) {
|
|
78
|
+
const locaUserid =
|
|
79
|
+
new Date().getTime() + "_" + Math.floor(Math.random() * 20);
|
|
80
|
+
this.meetingRequest = MeetingHandler.meetingStartRequestObject(
|
|
81
|
+
roomid,
|
|
82
|
+
userid || locaUserid,
|
|
83
|
+
"demo" || appName
|
|
84
|
+
);
|
|
85
|
+
this.meetingRequest.numberOfUsers = 2;
|
|
86
|
+
this.meetingRequest.userData = userData;
|
|
87
|
+
}
|
|
88
|
+
return this.meetingRequest;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then we will initialize the meeting and establish the connection by calling init method.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
MeetingHandler.init();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then we will call startLocalStream method of MeetingHandler which will ask for camera and mic permission, once given returns the localStream of the user itself.
|
|
100
|
+
It accepts `isVideoRequired` and `isAudioRequired` as its params.
|
|
101
|
+
|
|
102
|
+
* `isVideoRequired` : boolean
|
|
103
|
+
* `isAudioRequired` : boolean
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
MeetingHandler.startLocalStream();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then we will call checkSocket method of MeetingHandler to establish a connection with web socket.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
MeetingHandler.checkSocket();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
After the connection is established with the websocket we will recieve an `onConnected` event and pass event name "onConnected" as first params and pass callback function `onConnected` as second parameter which will call `startMeeting` method of MeetingHandler to start the meeting.
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
MeetingHandler.eventEmitter.on("onConnected", this.onConnected);
|
|
119
|
+
onConnected = () => {
|
|
120
|
+
MeetingHandler.startMeeting();
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
After the initiation of meeting we will recieve an `onTrack` event and pass that event as event name "onTrack" as first params and pass callback function `onTrack` as second parameter which will recieve track as a parameter which will be passed as a `MediaStream` to `video` tag.
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
MeetingHandler.eventEmitter.on("onTrack", this.onTrack);
|
|
128
|
+
MeetingHandler.eventEmitter.on("refreshTrack", this.onTrack);*
|
|
129
|
+
onTrack(track) {
|
|
130
|
+
if (
|
|
131
|
+
track.track !== null &&
|
|
132
|
+
track &&
|
|
133
|
+
track.kind === "video" &&
|
|
134
|
+
track.isLocalTrack
|
|
135
|
+
) {
|
|
136
|
+
this.localVideoRef.current.srcObject = new MediaStream([track.track]);
|
|
137
|
+
this.localVideoRef.current.play();
|
|
138
|
+
} else if (track && track.track !== null && !track.isLocalTrack) {
|
|
139
|
+
if (track.kind === "video" && track) {
|
|
140
|
+
this.remoteVideoRef.current.srcObject = new MediaStream([track.track]);
|
|
141
|
+
this.remoteVideoRef.current.play();
|
|
142
|
+
} else {
|
|
143
|
+
if (track && track.track !== null) {
|
|
144
|
+
this.remoteAudioRef.current.srcObject = new MediaStream([
|
|
145
|
+
track.track,
|
|
146
|
+
]);
|
|
147
|
+
this.remoteAudioRef.current.play();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MeetingStartRequest, VaniEventListener, Device, MessagePayload } from ".";
|
|
2
|
+
import { GetDevicesType } from "./user-media-handler/UserMediaHandler";
|
|
3
|
+
import { Track } from "./model/Track";
|
|
4
|
+
import { TaskResponse } from "./model/TaskResponse";
|
|
5
|
+
import { Participant } from "./model/Participant";
|
|
6
|
+
export declare class MeetingHandler {
|
|
7
|
+
private meetingStartRequest?;
|
|
8
|
+
private videoCallHandler?;
|
|
9
|
+
private reactNativeWebrtcPlugin?;
|
|
10
|
+
private websocketCallHandler?;
|
|
11
|
+
private communicationHandler?;
|
|
12
|
+
private userMediaHandler?;
|
|
13
|
+
meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string): MeetingStartRequest;
|
|
14
|
+
endAndDestory(): void;
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
switchCamera(): void;
|
|
17
|
+
startLocalStream(isVideoRequired: boolean, isAudioRequired: boolean, shouldAddTrackImmediately?: boolean, userMediaPayload?: any): Promise<void>;
|
|
18
|
+
startScreenShare(isAudioRequired?: boolean, shouldAddTrackImmediately?: boolean, screensharePayload?: any): Promise<void>;
|
|
19
|
+
stopScreenSharing(): Promise<void>;
|
|
20
|
+
getDevices(deviceType: GetDevicesType): Promise<Device[] | undefined>;
|
|
21
|
+
pauseCamera(userId?: string): Promise<TaskResponse>;
|
|
22
|
+
muteUser(userId?: string): Promise<TaskResponse>;
|
|
23
|
+
resumeCamera(userId?: string): Promise<TaskResponse>;
|
|
24
|
+
unmute(userId?: string): Promise<TaskResponse>;
|
|
25
|
+
stopTrack(track: Track): void;
|
|
26
|
+
addCustomTrack(track: Track): void;
|
|
27
|
+
pauseIncomingTrack(track: Track): void;
|
|
28
|
+
resumeIncomingTrack(track: Track): void;
|
|
29
|
+
participantByUserId(userId: string): Participant | undefined;
|
|
30
|
+
updateParticipantData(participant: Participant): Participant | undefined;
|
|
31
|
+
getUpdatedParticipantsListFromServer(): void;
|
|
32
|
+
getAllParticipants(): Participant[];
|
|
33
|
+
getAllTracks(): Track[];
|
|
34
|
+
getTracksByParticipantId(participantId: string): Track[];
|
|
35
|
+
sendMessage(message: MessagePayload): TaskResponse;
|
|
36
|
+
getOldMessages(): Promise<void>;
|
|
37
|
+
onOldMessages(data: any): Promise<void>;
|
|
38
|
+
checkSocket(): Promise<void>;
|
|
39
|
+
startMeeting(): Promise<void>;
|
|
40
|
+
getMeetingStartTime(): Promise<void>;
|
|
41
|
+
getEventEmitter(): VaniEventListener | undefined;
|
|
42
|
+
private emitMessageToSource;
|
|
43
|
+
private cleanup;
|
|
44
|
+
private handleGA;
|
|
45
|
+
}
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { VaniEvent, MeetingStartRequest } from ".";
|
|
38
|
+
import { DynamicLibHelper } from "./utility/DynamicLibHelper";
|
|
39
|
+
import * as log from 'loglevel';
|
|
40
|
+
import { WebSocketBasicEvents, WebsocketHandler } from "./websocket-handler/WebsocketHandler";
|
|
41
|
+
import { CommunicationHandler } from "./inter-communication-handler/CommunicationHandler";
|
|
42
|
+
import { UserMediaHandler } from "./user-media-handler/UserMediaHandler";
|
|
43
|
+
var MeetingHandler = /** @class */ (function () {
|
|
44
|
+
function MeetingHandler() {
|
|
45
|
+
this.communicationHandler = new CommunicationHandler(this);
|
|
46
|
+
}
|
|
47
|
+
MeetingHandler.prototype.meetingStartRequestObject = function (roomId, userId, appId, wssUrl) {
|
|
48
|
+
if (!this.meetingStartRequest) {
|
|
49
|
+
if (roomId === userId) {
|
|
50
|
+
roomId = roomId + "-r";
|
|
51
|
+
}
|
|
52
|
+
this.meetingStartRequest = new MeetingStartRequest(roomId, userId, appId, wssUrl);
|
|
53
|
+
}
|
|
54
|
+
return this.meetingStartRequest;
|
|
55
|
+
};
|
|
56
|
+
MeetingHandler.prototype.endAndDestory = function () {
|
|
57
|
+
this.cleanup();
|
|
58
|
+
};
|
|
59
|
+
MeetingHandler.prototype.init = function () {
|
|
60
|
+
var _a, _b, _c;
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var _d, _e;
|
|
63
|
+
return __generator(this, function (_f) {
|
|
64
|
+
switch (_f.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (!this.meetingStartRequest) {
|
|
67
|
+
log.error("meetingStartRequestObject not found");
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
log.setLevel("trace");
|
|
71
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.setMeetingStartRequest(this.meetingStartRequest);
|
|
72
|
+
if (!((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp)) return [3 /*break*/, 2];
|
|
73
|
+
_d = this;
|
|
74
|
+
return [4 /*yield*/, new DynamicLibHelper().getReactNativeWebrtcPlugin(this.meetingStartRequest)];
|
|
75
|
+
case 1:
|
|
76
|
+
_d.reactNativeWebrtcPlugin = _f.sent();
|
|
77
|
+
this.reactNativeWebrtcPlugin.registerGlobals();
|
|
78
|
+
_f.label = 2;
|
|
79
|
+
case 2:
|
|
80
|
+
_e = this;
|
|
81
|
+
return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.meetingType, this.meetingStartRequest, this.communicationHandler)];
|
|
82
|
+
case 3:
|
|
83
|
+
_e.videoCallHandler = _f.sent();
|
|
84
|
+
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
|
|
85
|
+
this.handleGA();
|
|
86
|
+
this.emitMessageToSource(VaniEvent.OnInitDone, {});
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
MeetingHandler.prototype.switchCamera = function () {
|
|
93
|
+
var _a;
|
|
94
|
+
(_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.switchCamera();
|
|
95
|
+
};
|
|
96
|
+
MeetingHandler.prototype.startLocalStream = function (isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload) {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (shouldAddTrackImmediately === void 0) { shouldAddTrackImmediately = true; }
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
return __generator(this, function (_c) {
|
|
101
|
+
if (!this.meetingStartRequest) {
|
|
102
|
+
log.error("meetingStartRequestObject not found");
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
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) {
|
|
106
|
+
log.error("Init method not called");
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
if (isVideoRequired === false && isAudioRequired === false) {
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
if (!this.userMediaHandler) {
|
|
113
|
+
this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
|
|
114
|
+
}
|
|
115
|
+
this.userMediaHandler.startLocalStream(isVideoRequired, isAudioRequired, shouldAddTrackImmediately, userMediaPayload);
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
MeetingHandler.prototype.startScreenShare = function (isAudioRequired, shouldAddTrackImmediately, screensharePayload) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
if (isAudioRequired === void 0) { isAudioRequired = false; }
|
|
123
|
+
if (shouldAddTrackImmediately === void 0) { shouldAddTrackImmediately = true; }
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
return __generator(this, function (_c) {
|
|
126
|
+
if (!this.meetingStartRequest) {
|
|
127
|
+
log.error("meetingStartRequestObject not found");
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
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) {
|
|
131
|
+
log.error("Init method not called");
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
}
|
|
134
|
+
if (!this.userMediaHandler) {
|
|
135
|
+
this.userMediaHandler = new UserMediaHandler(this.meetingStartRequest, this.communicationHandler);
|
|
136
|
+
}
|
|
137
|
+
this.userMediaHandler.startScreenShare(isAudioRequired, shouldAddTrackImmediately, screensharePayload);
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
MeetingHandler.prototype.stopScreenSharing = function () {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
if (this.userMediaHandler) {
|
|
146
|
+
this.userMediaHandler.stopScreenSharing();
|
|
147
|
+
}
|
|
148
|
+
return [2 /*return*/];
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
MeetingHandler.prototype.getDevices = function (deviceType) {
|
|
153
|
+
var _a;
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
return __generator(this, function (_b) {
|
|
156
|
+
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.getDevice(deviceType)];
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
MeetingHandler.prototype.pauseCamera = function (userId) {
|
|
161
|
+
var _a;
|
|
162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
return __generator(this, function (_b) {
|
|
165
|
+
if (this.userMediaHandler) {
|
|
166
|
+
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.pauseCamera(userId)];
|
|
167
|
+
}
|
|
168
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
|
|
171
|
+
return [2 /*return*/];
|
|
172
|
+
});
|
|
173
|
+
}); })];
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
MeetingHandler.prototype.muteUser = function (userId) {
|
|
178
|
+
var _a;
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var _this = this;
|
|
181
|
+
return __generator(this, function (_b) {
|
|
182
|
+
if (this.userMediaHandler) {
|
|
183
|
+
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.muteUser(userId)];
|
|
184
|
+
}
|
|
185
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
|
|
188
|
+
return [2 /*return*/];
|
|
189
|
+
});
|
|
190
|
+
}); })];
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
MeetingHandler.prototype.resumeCamera = function (userId) {
|
|
195
|
+
var _a;
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
var _this = this;
|
|
198
|
+
return __generator(this, function (_b) {
|
|
199
|
+
if (this.userMediaHandler) {
|
|
200
|
+
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.resumeCamera(userId)];
|
|
201
|
+
}
|
|
202
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
|
|
205
|
+
return [2 /*return*/];
|
|
206
|
+
});
|
|
207
|
+
}); })];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
MeetingHandler.prototype.unmute = function (userId) {
|
|
212
|
+
var _a;
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
var _this = this;
|
|
215
|
+
return __generator(this, function (_b) {
|
|
216
|
+
if (this.userMediaHandler) {
|
|
217
|
+
return [2 /*return*/, (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.unmute(userId)];
|
|
218
|
+
}
|
|
219
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
resolve({ message: "User Media Handler not found", error: 'InvalidMeetingRequest', isSuccess: false });
|
|
222
|
+
return [2 /*return*/];
|
|
223
|
+
});
|
|
224
|
+
}); })];
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
MeetingHandler.prototype.stopTrack = function (track) {
|
|
229
|
+
var _a;
|
|
230
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.removeTrack(track);
|
|
231
|
+
};
|
|
232
|
+
MeetingHandler.prototype.addCustomTrack = function (track) {
|
|
233
|
+
var _a;
|
|
234
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.addUpdateLocalTrack(track);
|
|
235
|
+
};
|
|
236
|
+
MeetingHandler.prototype.pauseIncomingTrack = function (track) {
|
|
237
|
+
var _a;
|
|
238
|
+
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.pauseIncomingTrack(track);
|
|
239
|
+
};
|
|
240
|
+
MeetingHandler.prototype.resumeIncomingTrack = function (track) {
|
|
241
|
+
var _a;
|
|
242
|
+
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.resumeIncomingTrack(track);
|
|
243
|
+
};
|
|
244
|
+
//Participant
|
|
245
|
+
MeetingHandler.prototype.participantByUserId = function (userId) {
|
|
246
|
+
var _a, _b, _c;
|
|
247
|
+
if (this.meetingStartRequest) {
|
|
248
|
+
if (userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
|
|
249
|
+
return (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getSelfParticipant();
|
|
250
|
+
}
|
|
251
|
+
return (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.participantByUserId(userId);
|
|
252
|
+
}
|
|
253
|
+
return undefined;
|
|
254
|
+
};
|
|
255
|
+
MeetingHandler.prototype.updateParticipantData = function (participant) {
|
|
256
|
+
var _a;
|
|
257
|
+
var oldParticipant = this.participantByUserId(participant.userId);
|
|
258
|
+
if (oldParticipant) {
|
|
259
|
+
Object.assign(oldParticipant, participant);
|
|
260
|
+
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(WebSocketBasicEvents.UpdateParticipant, oldParticipant);
|
|
261
|
+
}
|
|
262
|
+
return oldParticipant;
|
|
263
|
+
};
|
|
264
|
+
MeetingHandler.prototype.getUpdatedParticipantsListFromServer = function () {
|
|
265
|
+
var _a;
|
|
266
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
|
|
267
|
+
};
|
|
268
|
+
MeetingHandler.prototype.getAllParticipants = function () {
|
|
269
|
+
if (this.communicationHandler) {
|
|
270
|
+
return this.communicationHandler.getAllParticipants();
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
MeetingHandler.prototype.getAllTracks = function () {
|
|
277
|
+
if (this.communicationHandler) {
|
|
278
|
+
return this.communicationHandler.getAllTracks();
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
MeetingHandler.prototype.getTracksByParticipantId = function (participantId) {
|
|
285
|
+
var participant = this.participantByUserId(participantId);
|
|
286
|
+
if (participant) {
|
|
287
|
+
if (this.communicationHandler) {
|
|
288
|
+
return this.communicationHandler.getAllTracksForParticipant(participant);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return [];
|
|
292
|
+
};
|
|
293
|
+
///Messages
|
|
294
|
+
MeetingHandler.prototype.sendMessage = function (message) {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
if (!message.sender) {
|
|
297
|
+
message.sender = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
|
|
298
|
+
}
|
|
299
|
+
if (!message.sender || !this.meetingStartRequest) {
|
|
300
|
+
return { message: "Invalid Meeting Request", error: 'InvalidMeetingRequest', isSuccess: false };
|
|
301
|
+
}
|
|
302
|
+
message.senderUserId = message.sender.userId;
|
|
303
|
+
if (message.sender.isMessageBlockedByAdmin) {
|
|
304
|
+
return { message: "Blocked By Admin", error: 'BlockedByAdmin', isSuccess: false };
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
var to = message.to === "all" ? this.meetingStartRequest.roomId : message.to;
|
|
308
|
+
var messageObj = { type: "chat", message: message.toJsonObjectForSending(), to: to, shouldPresist: message.shouldPresist };
|
|
309
|
+
(_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.Message, messageObj);
|
|
310
|
+
return { message: "Message Sent", error: 'NoError', isSuccess: true };
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
MeetingHandler.prototype.getOldMessages = function () {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
+
return __generator(this, function (_a) {
|
|
316
|
+
log.info("getOldMessages");
|
|
317
|
+
if (this.websocketCallHandler) {
|
|
318
|
+
this.websocketCallHandler.sendSocketMessage(WebSocketBasicEvents.GetOldMessages, {});
|
|
319
|
+
}
|
|
320
|
+
return [2 /*return*/];
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
MeetingHandler.prototype.onOldMessages = function (data) {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
326
|
+
return __generator(this, function (_a) {
|
|
327
|
+
log.info(data);
|
|
328
|
+
return [2 /*return*/];
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
MeetingHandler.prototype.checkSocket = function () {
|
|
333
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
334
|
+
return __generator(this, function (_a) {
|
|
335
|
+
if (!this.meetingStartRequest) {
|
|
336
|
+
log.error("meetingStartRequestObject not found");
|
|
337
|
+
return [2 /*return*/];
|
|
338
|
+
}
|
|
339
|
+
if (!this.websocketCallHandler) {
|
|
340
|
+
log.error("Init method not called");
|
|
341
|
+
return [2 /*return*/];
|
|
342
|
+
}
|
|
343
|
+
log.info("checkSocket");
|
|
344
|
+
this.websocketCallHandler.startSocketConnection();
|
|
345
|
+
return [2 /*return*/];
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
MeetingHandler.prototype.startMeeting = function () {
|
|
350
|
+
var _a;
|
|
351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
+
return __generator(this, function (_b) {
|
|
353
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.onStartMeeingCalled();
|
|
354
|
+
return [2 /*return*/];
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
MeetingHandler.prototype.getMeetingStartTime = function () {
|
|
359
|
+
var _a, _b;
|
|
360
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
361
|
+
var meetingStartTimeObject;
|
|
362
|
+
return __generator(this, function (_c) {
|
|
363
|
+
if (!this.meetingStartRequest) {
|
|
364
|
+
log.error("meetingStartRequestObject not found");
|
|
365
|
+
return [2 /*return*/];
|
|
366
|
+
}
|
|
367
|
+
if (!this.websocketCallHandler) {
|
|
368
|
+
log.error("Init method not called");
|
|
369
|
+
return [2 /*return*/];
|
|
370
|
+
}
|
|
371
|
+
meetingStartTimeObject = { type: WebSocketBasicEvents.GetMeetingStartTime, to: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId };
|
|
372
|
+
(_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.sendSocketMessage(WebSocketBasicEvents.GetMeetingStartTime, meetingStartTimeObject);
|
|
373
|
+
return [2 /*return*/];
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
MeetingHandler.prototype.getEventEmitter = function () {
|
|
378
|
+
var _a;
|
|
379
|
+
return (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getEventEmitter();
|
|
380
|
+
};
|
|
381
|
+
MeetingHandler.prototype.emitMessageToSource = function (emitType, payload) {
|
|
382
|
+
var _a;
|
|
383
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
+
return __generator(this, function (_b) {
|
|
385
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(emitType, payload);
|
|
386
|
+
return [2 /*return*/];
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
MeetingHandler.prototype.cleanup = function () {
|
|
391
|
+
var _a, _b, _c;
|
|
392
|
+
this.meetingStartRequest = undefined;
|
|
393
|
+
this.reactNativeWebrtcPlugin = undefined;
|
|
394
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
395
|
+
this.communicationHandler = undefined;
|
|
396
|
+
(_b = this.videoCallHandler) === null || _b === void 0 ? void 0 : _b.cleanup();
|
|
397
|
+
this.videoCallHandler = undefined;
|
|
398
|
+
(_c = this.websocketCallHandler) === null || _c === void 0 ? void 0 : _c.cleanup();
|
|
399
|
+
this.websocketCallHandler = undefined;
|
|
400
|
+
};
|
|
401
|
+
MeetingHandler.prototype.handleGA = function () {
|
|
402
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
403
|
+
return __generator(this, function (_a) {
|
|
404
|
+
return [2 /*return*/];
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
return MeetingHandler;
|
|
409
|
+
}());
|
|
410
|
+
export { MeetingHandler };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MeetingStartRequest } from "..";
|
|
2
|
+
import { CommunicationHandler } from "../inter-communication-handler/CommunicationHandler";
|
|
3
|
+
export declare abstract class Base {
|
|
4
|
+
protected meetingStartRequest?: MeetingStartRequest;
|
|
5
|
+
protected communicationHandler?: CommunicationHandler;
|
|
6
|
+
constructor(_meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler);
|
|
7
|
+
protected onObjectCreated(): void;
|
|
8
|
+
cleanup(): void;
|
|
9
|
+
}
|
package/lib/base/Base.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as log from 'loglevel';
|
|
2
|
+
var Base = /** @class */ (function () {
|
|
3
|
+
function Base(_meetingStartRequest, _communicationHandler) {
|
|
4
|
+
this.meetingStartRequest = _meetingStartRequest;
|
|
5
|
+
this.communicationHandler = _communicationHandler;
|
|
6
|
+
this.onObjectCreated();
|
|
7
|
+
}
|
|
8
|
+
Base.prototype.onObjectCreated = function () {
|
|
9
|
+
log.info("Object created");
|
|
10
|
+
};
|
|
11
|
+
Base.prototype.cleanup = function () {
|
|
12
|
+
this.communicationHandler = undefined;
|
|
13
|
+
this.meetingStartRequest = undefined;
|
|
14
|
+
log.info("cleanup");
|
|
15
|
+
};
|
|
16
|
+
return Base;
|
|
17
|
+
}());
|
|
18
|
+
export { Base };
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED