vani-meeting-server 1.0.1 → 1.0.2
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/lib/ServerHandler.d.ts +13 -0
- package/lib/ServerHandler.js +35 -0
- package/lib/base/BaseSFUWebsocket.d.ts +7 -0
- package/lib/base/BaseSFUWebsocket.js +24 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/lib/redis/RedisHandler.d.ts +28 -0
- package/lib/lib/redis/RedisHandler.js +148 -0
- package/{src/models/Event.ts → lib/models/Event.d.ts} +9 -20
- package/lib/models/Event.js +8 -0
- package/lib/models/MessagePayload.d.ts +19 -0
- package/lib/models/MessagePayload.js +29 -0
- package/lib/models/Participant.d.ts +15 -0
- package/lib/models/Participant.js +20 -0
- package/lib/models/WebSocketServerStartRequest.d.ts +9 -0
- package/lib/models/WebSocketServerStartRequest.js +11 -0
- package/lib/sfu/SFUEachRoomHandler.d.ts +56 -0
- package/lib/sfu/SFUEachRoomHandler.js +206 -0
- package/lib/sfu/SFUEachRoomUserHandler.d.ts +36 -0
- package/lib/sfu/SFUEachRoomUserHandler.js +433 -0
- package/lib/sfu/SFUHandler.d.ts +13 -0
- package/lib/sfu/SFUHandler.js +64 -0
- package/lib/utility/Constant.d.ts +15 -0
- package/lib/utility/Constant.js +69 -0
- package/lib/utility/EventEmitterHandler.d.ts +6 -0
- package/lib/utility/EventEmitterHandler.js +10 -0
- package/lib/utility/VaniEventListener.d.ts +4 -0
- package/{src/utility/VaniEventListener.ts → lib/utility/VaniEventListener.js} +0 -4
- package/lib/websocket/EachSocketConnectionHandler.d.ts +119 -0
- package/lib/websocket/EachSocketConnectionHandler.js +427 -0
- package/lib/websocket/WebSocketHandler.d.ts +6 -0
- package/{src/websocket/WebSocketHandler.ts → lib/websocket/WebSocketHandler.js} +13 -17
- package/package.json +7 -3
- package/dump.rdb +0 -0
- package/pm2.config.js +0 -8
- package/src/ServerHandler.ts +0 -32
- package/src/base/BaseSFUWebsocket.ts +0 -20
- package/src/index.ts +0 -3
- package/src/lib/redis/RedisHandler.ts +0 -150
- package/src/models/MessagePayload.ts +0 -35
- package/src/models/Participant.ts +0 -24
- package/src/models/WebSocketServerStartRequest.ts +0 -14
- package/src/sfu/SFUEachRoomHandler.ts +0 -265
- package/src/sfu/SFUEachRoomUserHandler.ts +0 -468
- package/src/sfu/SFUHandler.ts +0 -67
- package/src/utility/Constant.ts +0 -63
- package/src/utility/EventEmitterHandler.ts +0 -10
- package/src/websocket/EachSocketConnectionHandler.ts +0 -451
- package/tsconfig.json +0 -12
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RedisHandler } from "./lib/redis/RedisHandler";
|
|
2
|
+
import { WebSocketServerStartRequest } from "./models/WebSocketServerStartRequest";
|
|
3
|
+
import { SFUHandler } from "./sfu/SFUHandler";
|
|
4
|
+
import { WebSocketHandler } from "./websocket/WebSocketHandler";
|
|
5
|
+
export declare class ServerHandler {
|
|
6
|
+
serverStartRequest: WebSocketServerStartRequest;
|
|
7
|
+
rediHandler?: RedisHandler;
|
|
8
|
+
webSocketHandler?: WebSocketHandler;
|
|
9
|
+
sfuHandler?: SFUHandler;
|
|
10
|
+
static instance: ServerHandler;
|
|
11
|
+
static getInstance(): ServerHandler;
|
|
12
|
+
initWithServerStartRequest(serverStartRequest: WebSocketServerStartRequest): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import { RedisHandler } from "./lib/redis/RedisHandler";
|
|
11
|
+
import { WebSocketServerStartRequest } from "./models/WebSocketServerStartRequest";
|
|
12
|
+
import { SFUHandler } from "./sfu/SFUHandler";
|
|
13
|
+
import { WebSocketHandler } from "./websocket/WebSocketHandler";
|
|
14
|
+
export class ServerHandler {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.serverStartRequest = new WebSocketServerStartRequest();
|
|
17
|
+
}
|
|
18
|
+
static getInstance() {
|
|
19
|
+
return ServerHandler.instance;
|
|
20
|
+
}
|
|
21
|
+
initWithServerStartRequest(serverStartRequest) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
this.serverStartRequest = serverStartRequest;
|
|
24
|
+
this.rediHandler = RedisHandler.getInstance();
|
|
25
|
+
yield this.rediHandler.connectDB();
|
|
26
|
+
yield this.rediHandler.cleanUp();
|
|
27
|
+
console.info("On Redis Connected");
|
|
28
|
+
this.webSocketHandler = new WebSocketHandler();
|
|
29
|
+
this.webSocketHandler.connect();
|
|
30
|
+
this.sfuHandler = SFUHandler.getInstance();
|
|
31
|
+
this.sfuHandler.init();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
ServerHandler.instance = new ServerHandler();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Participant } from "../models/Participant";
|
|
2
|
+
import { ClientMessageBody, WebSocketEvents, WebSocketMessageBody } from "../websocket/EachSocketConnectionHandler";
|
|
3
|
+
export declare class BaseSFUWebsocket {
|
|
4
|
+
protected redisBroadcastMessageToTopic(topic: string, data: WebSocketMessageBody | ClientMessageBody): Promise<void>;
|
|
5
|
+
protected preapreClientMessageBody(shouldSendToSelf: boolean, senderParticipant: Participant, broadcastMessage: WebSocketMessageBody): ClientMessageBody;
|
|
6
|
+
protected preapreWebSocketMessageBody(type: WebSocketEvents, data: any): WebSocketMessageBody;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { RedisHandler } from "../lib/redis/RedisHandler";
|
|
11
|
+
export class BaseSFUWebsocket {
|
|
12
|
+
redisBroadcastMessageToTopic(topic, data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
RedisHandler.getInstance().redisPublisher.publish(topic, JSON.stringify(data));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//Utilility function
|
|
18
|
+
preapreClientMessageBody(shouldSendToSelf, senderParticipant, broadcastMessage) {
|
|
19
|
+
return { shouldSendToSelf, senderParticipant, broadcastMessage, interfaceName: 'ClientMessageBody' };
|
|
20
|
+
}
|
|
21
|
+
preapreWebSocketMessageBody(type, data) {
|
|
22
|
+
return { type, data, interfaceName: 'WebSocketMessageBody' };
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RedisClientType } from "redis";
|
|
2
|
+
import { MessagePayload } from "../../models/MessagePayload";
|
|
3
|
+
import { Participant } from "../../models/Participant";
|
|
4
|
+
export declare enum RedisKeyType {
|
|
5
|
+
Messages = "messages",
|
|
6
|
+
MeetingTime = "meetingTime",
|
|
7
|
+
Participants = "participants"
|
|
8
|
+
}
|
|
9
|
+
export declare class RedisHandler {
|
|
10
|
+
private static redisHandler;
|
|
11
|
+
private redisClient;
|
|
12
|
+
redisPublisher: RedisClientType;
|
|
13
|
+
redisSubscriber: RedisClientType;
|
|
14
|
+
constructor();
|
|
15
|
+
static getInstance(): RedisHandler;
|
|
16
|
+
connectDB(): Promise<void>;
|
|
17
|
+
cleanUp(): Promise<string>;
|
|
18
|
+
cleanUpRoomId(roomId: string): Promise<void>;
|
|
19
|
+
storeMesagesForRoom(roomId: string, messagePayload: MessagePayload): Promise<void>;
|
|
20
|
+
fetchMessagesForRoom(roomId: string): Promise<MessagePayload[]>;
|
|
21
|
+
storeMeetingTimeForRoom(roomId: string, time?: number): Promise<void>;
|
|
22
|
+
fetchMeetingTimeForRoom(roomId: string): Promise<number | undefined>;
|
|
23
|
+
removeParticipantForRoom(roomId: string, participant: Participant): Promise<void>;
|
|
24
|
+
addUpdateParticipantForRoom(roomId: string, participant: Participant): Promise<void>;
|
|
25
|
+
getParticipantByUserId(roomId: string, userId: string): Promise<Participant | undefined>;
|
|
26
|
+
getAllParticipants(roomId: string): Promise<Participant[]>;
|
|
27
|
+
private updateRoomCleanupTimeOut;
|
|
28
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
import { createClient } from "redis";
|
|
11
|
+
import { Participant } from "../../models/Participant";
|
|
12
|
+
import { ServerHandler } from "../../ServerHandler";
|
|
13
|
+
export var RedisKeyType;
|
|
14
|
+
(function (RedisKeyType) {
|
|
15
|
+
RedisKeyType["Messages"] = "messages";
|
|
16
|
+
RedisKeyType["MeetingTime"] = "meetingTime";
|
|
17
|
+
RedisKeyType["Participants"] = "participants";
|
|
18
|
+
})(RedisKeyType || (RedisKeyType = {}));
|
|
19
|
+
export class RedisHandler {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.redisClient = createClient({ url: ServerHandler.getInstance().serverStartRequest.redisUrl, database: ServerHandler.getInstance().serverStartRequest.redisDBIndex });
|
|
22
|
+
this.redisSubscriber = createClient({ url: ServerHandler.getInstance().serverStartRequest.redisUrl });
|
|
23
|
+
this.redisPublisher = createClient({ url: ServerHandler.getInstance().serverStartRequest.redisUrl });
|
|
24
|
+
}
|
|
25
|
+
static getInstance() {
|
|
26
|
+
return this.redisHandler;
|
|
27
|
+
}
|
|
28
|
+
connectDB() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
this.redisClient.on("connect", (data) => {
|
|
31
|
+
console.info('Redis has been connected successfully.', data);
|
|
32
|
+
});
|
|
33
|
+
this.redisClient.on('end', (err) => {
|
|
34
|
+
console.error('Redis connection has been closed.', err);
|
|
35
|
+
});
|
|
36
|
+
this.redisClient.on('error', (err) => {
|
|
37
|
+
console.error('Unknown exception occurred at Redis', err);
|
|
38
|
+
});
|
|
39
|
+
yield this.redisClient.connect();
|
|
40
|
+
yield this.redisSubscriber.connect();
|
|
41
|
+
yield this.redisPublisher.connect();
|
|
42
|
+
// await this.redisClient.hSet("rooms","123","HSETObject")
|
|
43
|
+
// console.log(await this.redisClient.hGet("rooms","123"))
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
cleanUp() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return yield this.redisClient.flushDb();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//Clean Room Id
|
|
52
|
+
cleanUpRoomId(roomId) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
yield this.redisClient.del(roomId);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//Messages
|
|
58
|
+
storeMesagesForRoom(roomId, messagePayload) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const messages = yield this.fetchMessagesForRoom(roomId);
|
|
61
|
+
messages.push(messagePayload);
|
|
62
|
+
yield this.redisClient.hSet(roomId, RedisKeyType.Messages, JSON.stringify(messages));
|
|
63
|
+
this.updateRoomCleanupTimeOut(roomId);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
fetchMessagesForRoom(roomId) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const messages = yield this.redisClient.hGet(roomId, RedisKeyType.Messages);
|
|
69
|
+
if (messages) {
|
|
70
|
+
return JSON.parse(messages);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//Meeting Time
|
|
78
|
+
storeMeetingTimeForRoom(roomId, time) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
yield this.redisClient.hSet(roomId, RedisKeyType.MeetingTime, time ? time : new Date().getTime());
|
|
81
|
+
this.updateRoomCleanupTimeOut(roomId);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
fetchMeetingTimeForRoom(roomId) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const meetingTime = yield this.redisClient.hGet(roomId, RedisKeyType.MeetingTime);
|
|
87
|
+
if (meetingTime) {
|
|
88
|
+
return +meetingTime;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//Users
|
|
96
|
+
removeParticipantForRoom(roomId, participant) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const participantKey = RedisKeyType.Participants + ":" + participant.userId;
|
|
99
|
+
yield this.redisClient.hDel(roomId, participantKey);
|
|
100
|
+
this.updateRoomCleanupTimeOut(roomId);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
addUpdateParticipantForRoom(roomId, participant) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const participantKey = RedisKeyType.Participants + ":" + participant.userId;
|
|
106
|
+
yield this.redisClient.hSet(roomId, participantKey, JSON.stringify(participant));
|
|
107
|
+
this.updateRoomCleanupTimeOut(roomId);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getParticipantByUserId(roomId, userId) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const participantKey = RedisKeyType.Participants + ":" + userId;
|
|
113
|
+
const particpantString = yield this.redisClient.hGet(roomId, participantKey);
|
|
114
|
+
if (particpantString) {
|
|
115
|
+
return JSON.parse(particpantString);
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
getAllParticipants(roomId) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const particpantsInStringify = yield this.redisClient.hGetAll(roomId);
|
|
123
|
+
const participants = [];
|
|
124
|
+
if (particpantsInStringify) {
|
|
125
|
+
Object.entries(particpantsInStringify).forEach(([key, value]) => {
|
|
126
|
+
if (key.includes(RedisKeyType.Participants)) {
|
|
127
|
+
participants.push(Object.assign(new Participant(), JSON.parse(value)));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return participants;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// private getRediRoomModelForRoomId(roomId: string): RedisRoomModel {
|
|
135
|
+
// if (this.redisRoomModelHash.has(roomId)) {
|
|
136
|
+
// return this.redisRoomModelHash.get(roomId)!
|
|
137
|
+
// }
|
|
138
|
+
// else {
|
|
139
|
+
// const redisRoomModel = new RedisRoomModel(roomId)
|
|
140
|
+
// this.redisRoomModelHash.set(roomId, redisRoomModel)
|
|
141
|
+
// return redisRoomModel
|
|
142
|
+
// }
|
|
143
|
+
// }
|
|
144
|
+
updateRoomCleanupTimeOut(roomId) {
|
|
145
|
+
this.redisClient.expire(roomId, ServerHandler.getInstance().serverStartRequest.redisRoomDestoryTimeOutInSec);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
RedisHandler.redisHandler = new RedisHandler();
|
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
import { Participant } from "./Participant";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export enum VaniEvent {
|
|
5
|
-
|
|
2
|
+
export declare enum VaniEvent {
|
|
6
3
|
OnNewMeetingStarted = "onNewMeetingStarted",
|
|
7
4
|
OnNewMeetingEnded = "onNewMeetingEnded",
|
|
8
5
|
OnUserJoined = "onUserJoined",
|
|
9
6
|
OnUserLeft = "onUserLeft",
|
|
10
7
|
OnServerStarted = "onServerStarted"
|
|
11
|
-
|
|
12
|
-
|
|
13
8
|
}
|
|
14
|
-
|
|
15
9
|
interface VaniConnectionEvents {
|
|
16
|
-
[VaniEvent.OnNewMeetingStarted]: (roomId
|
|
17
|
-
[VaniEvent.OnNewMeetingEnded]: (roomId
|
|
18
|
-
[VaniEvent.OnUserJoined]: (participant
|
|
19
|
-
[VaniEvent.OnUserLeft]: (participant
|
|
10
|
+
[VaniEvent.OnNewMeetingStarted]: (roomId: string) => any;
|
|
11
|
+
[VaniEvent.OnNewMeetingEnded]: (roomId: string) => any;
|
|
12
|
+
[VaniEvent.OnUserJoined]: (participant: Participant) => any;
|
|
13
|
+
[VaniEvent.OnUserLeft]: (participant: Participant) => any;
|
|
20
14
|
[VaniEvent.OnServerStarted]: () => any;
|
|
21
|
-
|
|
22
|
-
// [VaniEvent.OnSocketError]: (error: any) => any;
|
|
23
15
|
}
|
|
24
|
-
|
|
25
16
|
export declare interface VaniEventListener {
|
|
26
17
|
on<U extends keyof VaniConnectionEvents>(event: U, listener: VaniConnectionEvents[U]): this;
|
|
27
18
|
off<U extends keyof VaniConnectionEvents>(event: U, listener: VaniConnectionEvents[U]): this;
|
|
28
19
|
emit<U extends keyof VaniConnectionEvents>(event: U, ...args: Parameters<VaniConnectionEvents[U]>): boolean;
|
|
29
20
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
21
|
export interface Device {
|
|
34
|
-
id: string
|
|
35
|
-
label: string
|
|
36
|
-
}
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var VaniEvent;
|
|
2
|
+
(function (VaniEvent) {
|
|
3
|
+
VaniEvent["OnNewMeetingStarted"] = "onNewMeetingStarted";
|
|
4
|
+
VaniEvent["OnNewMeetingEnded"] = "onNewMeetingEnded";
|
|
5
|
+
VaniEvent["OnUserJoined"] = "onUserJoined";
|
|
6
|
+
VaniEvent["OnUserLeft"] = "onUserLeft";
|
|
7
|
+
VaniEvent["OnServerStarted"] = "onServerStarted";
|
|
8
|
+
})(VaniEvent || (VaniEvent = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum ChatMessageType {
|
|
2
|
+
Chat = "chat",
|
|
3
|
+
File = "file",
|
|
4
|
+
Info = "info"
|
|
5
|
+
}
|
|
6
|
+
export declare enum ChatSendVia {
|
|
7
|
+
WebSocket = "WebSocket",
|
|
8
|
+
DataChannel = "DataChannel"
|
|
9
|
+
}
|
|
10
|
+
export declare class MessagePayload {
|
|
11
|
+
message?: string;
|
|
12
|
+
to: string;
|
|
13
|
+
extraData: any;
|
|
14
|
+
type?: ChatMessageType | string;
|
|
15
|
+
senderUserId?: string;
|
|
16
|
+
shouldPresist: boolean;
|
|
17
|
+
time: number;
|
|
18
|
+
chatSendVia: ChatSendVia;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export var ChatMessageType;
|
|
2
|
+
(function (ChatMessageType) {
|
|
3
|
+
ChatMessageType["Chat"] = "chat";
|
|
4
|
+
ChatMessageType["File"] = "file";
|
|
5
|
+
ChatMessageType["Info"] = "info";
|
|
6
|
+
})(ChatMessageType || (ChatMessageType = {}));
|
|
7
|
+
export var ChatSendVia;
|
|
8
|
+
(function (ChatSendVia) {
|
|
9
|
+
ChatSendVia["WebSocket"] = "WebSocket";
|
|
10
|
+
ChatSendVia["DataChannel"] = "DataChannel";
|
|
11
|
+
})(ChatSendVia || (ChatSendVia = {}));
|
|
12
|
+
export class MessagePayload {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.to = "all";
|
|
15
|
+
this.extraData = {};
|
|
16
|
+
// public sender? :Participant;
|
|
17
|
+
this.shouldPresist = false;
|
|
18
|
+
this.time = new Date().getTime();
|
|
19
|
+
this.chatSendVia = ChatSendVia.WebSocket;
|
|
20
|
+
// constructor( _message : string)
|
|
21
|
+
// constructor( _message : string , _to: string )
|
|
22
|
+
// constructor(_message : string , _to: string = "all" , _sender ? : Participant , _type : ChatMessageType | string = ChatMessageType.Chat) {
|
|
23
|
+
// this.message = _message;
|
|
24
|
+
// this.to = _to;
|
|
25
|
+
// this.sender = _sender;
|
|
26
|
+
// this.type = _type;
|
|
27
|
+
// }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Participant {
|
|
2
|
+
userId?: string;
|
|
3
|
+
userData: any;
|
|
4
|
+
isAdmin: boolean;
|
|
5
|
+
isAudioBlockedByAdmin: boolean;
|
|
6
|
+
isVideoBlockedByAdmin: boolean;
|
|
7
|
+
isMessageBlockedByAdmin: boolean;
|
|
8
|
+
isWhiteboardBlockedByAdmin: boolean;
|
|
9
|
+
isScreenshareBlockedByAdmin: boolean;
|
|
10
|
+
roomId?: string;
|
|
11
|
+
isVideoEnable: boolean;
|
|
12
|
+
isAudioEnable: boolean;
|
|
13
|
+
isStartMeetingCalled: boolean;
|
|
14
|
+
isRecordingUser: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class Participant {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.isAdmin = false;
|
|
4
|
+
this.isAudioBlockedByAdmin = false;
|
|
5
|
+
this.isVideoBlockedByAdmin = false;
|
|
6
|
+
this.isMessageBlockedByAdmin = false;
|
|
7
|
+
this.isWhiteboardBlockedByAdmin = true;
|
|
8
|
+
this.isScreenshareBlockedByAdmin = false;
|
|
9
|
+
this.isVideoEnable = false;
|
|
10
|
+
this.isAudioEnable = false;
|
|
11
|
+
this.isStartMeetingCalled = false;
|
|
12
|
+
this.isRecordingUser = false;
|
|
13
|
+
// constructor(_userId: string, _roomId: string, _userData: any = {}, _isAdmin: boolean = false) {
|
|
14
|
+
// this.userId = _userId;
|
|
15
|
+
// this.roomId = _roomId;
|
|
16
|
+
// this.userData = _userData;
|
|
17
|
+
// this.isAdmin = _isAdmin;
|
|
18
|
+
// }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class WebSocketServerStartRequest {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.port = 4010;
|
|
4
|
+
this.redisUrl = "redis://127.0.0.1:6378";
|
|
5
|
+
this.redisDBIndex = 5;
|
|
6
|
+
this.redisRoomDestoryTimeOutInSec = 1800;
|
|
7
|
+
this.rtcMinPort = 40000;
|
|
8
|
+
this.rtcMaxPort = 59999;
|
|
9
|
+
this.isTCPConnection = false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Consumer } from "mediasoup/node/lib/Consumer";
|
|
2
|
+
import { Producer } from "mediasoup/node/lib/Producer";
|
|
3
|
+
import { Router } from "mediasoup/node/lib/Router";
|
|
4
|
+
import { Worker } from "mediasoup/node/lib/Worker";
|
|
5
|
+
import { BaseSFUWebsocket } from "../base/BaseSFUWebsocket";
|
|
6
|
+
import { Participant } from "../models/Participant";
|
|
7
|
+
import { SFUMessageType } from "../websocket/EachSocketConnectionHandler";
|
|
8
|
+
import { SFUEachRoomUserHandler } from "./SFUEachRoomUserHandler";
|
|
9
|
+
export interface SFUEachRoomParticipantInterface {
|
|
10
|
+
participant: Participant;
|
|
11
|
+
}
|
|
12
|
+
export interface SFUEachRoomProducer extends SFUEachRoomParticipantInterface {
|
|
13
|
+
producer: Producer;
|
|
14
|
+
}
|
|
15
|
+
export interface SFUEachRoomConsumer extends SFUEachRoomParticipantInterface {
|
|
16
|
+
consumer: Consumer;
|
|
17
|
+
}
|
|
18
|
+
export interface SFUMessageBody {
|
|
19
|
+
to: string;
|
|
20
|
+
type: SFUMessageType;
|
|
21
|
+
message: any;
|
|
22
|
+
}
|
|
23
|
+
export interface SFUEachRoomHandlerInterface {
|
|
24
|
+
getAllProducerForRoom(): SFUEachRoomProducer[];
|
|
25
|
+
getProducerById(producerId: string): SFUEachRoomProducer | undefined;
|
|
26
|
+
getAllConsumerForRoom(): SFUEachRoomConsumer[];
|
|
27
|
+
getAllRecvRouterForRoom(): Router[];
|
|
28
|
+
getSendRouterForRoom(): Router;
|
|
29
|
+
addAudioObserverForProducer(audioProducer: Producer): void;
|
|
30
|
+
pipeToRoute(producer: Producer): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare class SFUEachRoomHandler extends BaseSFUWebsocket implements SFUEachRoomHandlerInterface {
|
|
33
|
+
private recvRouter;
|
|
34
|
+
private sendRouter?;
|
|
35
|
+
private roomId;
|
|
36
|
+
roomPaticipants: Map<string, SFUEachRoomUserHandler>;
|
|
37
|
+
private workers?;
|
|
38
|
+
private sendWorkerIndex;
|
|
39
|
+
private audioObserver?;
|
|
40
|
+
constructor(roomId: string, workers: Worker[], sendWorkerIndex: number);
|
|
41
|
+
onNewMessage(payload: SFUMessageBody, participant: Participant): void;
|
|
42
|
+
private getEachRoomUserFromParticipant;
|
|
43
|
+
private onGetRTPCapabilities;
|
|
44
|
+
private setUpForRoomId;
|
|
45
|
+
private addAudioObserver;
|
|
46
|
+
private getWorkerIndexForCreatingRouter;
|
|
47
|
+
getProducerById(producerId: string): SFUEachRoomProducer | undefined;
|
|
48
|
+
getAllProducerForRoom(): SFUEachRoomProducer[];
|
|
49
|
+
getAllConsumerForRoom(): SFUEachRoomConsumer[];
|
|
50
|
+
getAllRecvRouterForRoom(): Router[];
|
|
51
|
+
getSendRouterForRoom(): Router;
|
|
52
|
+
pipeToRoute(producer: Producer): Promise<void>;
|
|
53
|
+
addAudioObserverForProducer(audioProducer: Producer): Promise<void>;
|
|
54
|
+
onUserLeft(participant: Participant): void;
|
|
55
|
+
cleanUp(): void;
|
|
56
|
+
}
|