@videosdk.live/react-sdk 0.1.10 → 0.1.14
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/dist/index.js +227 -12
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +227 -14
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { createContext, useEffect, useContext, useState, useRef, useMemo } from 'react';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
import {
|
|
3
|
+
import { VideoSDK } from '@videosdk.live/js-sdk';
|
|
4
4
|
|
|
5
|
-
var eventPrifix = '
|
|
5
|
+
var eventPrifix = 'videosdk-live-react-sdk';
|
|
6
6
|
var events = {
|
|
7
7
|
'participant-joined': eventPrifix + "-participant-joined",
|
|
8
8
|
'participant-left': eventPrifix + "-participant-left",
|
|
@@ -22,7 +22,11 @@ var events = {
|
|
|
22
22
|
'video-seeked': eventPrifix + "-video-seeked",
|
|
23
23
|
'webcam-requested': eventPrifix + "-webcam-requested",
|
|
24
24
|
'mic-requested': eventPrifix + "-mic-requested",
|
|
25
|
-
'pin-state-changed': eventPrifix + "-pin-state-changed"
|
|
25
|
+
'pin-state-changed': eventPrifix + "-pin-state-changed",
|
|
26
|
+
'connection-open': eventPrifix + "-connection-open",
|
|
27
|
+
'connection-close': eventPrifix + "-connection-close",
|
|
28
|
+
'switch-meeting': eventPrifix + "-switch-meeting",
|
|
29
|
+
error: eventPrifix + "-error"
|
|
26
30
|
};
|
|
27
31
|
var eventEmitter = new EventEmitter();
|
|
28
32
|
eventEmitter.setMaxListeners(9999);
|
|
@@ -67,7 +71,15 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
67
71
|
_ref$onMicRequested = _ref.onMicRequested,
|
|
68
72
|
onMicRequested = _ref$onMicRequested === void 0 ? function () {} : _ref$onMicRequested,
|
|
69
73
|
_ref$onPinStateChange = _ref.onPinStateChanged,
|
|
70
|
-
onPinStateChanged = _ref$onPinStateChange === void 0 ? function () {} : _ref$onPinStateChange
|
|
74
|
+
onPinStateChanged = _ref$onPinStateChange === void 0 ? function () {} : _ref$onPinStateChange,
|
|
75
|
+
_ref$onConnectionOpen = _ref.onConnectionOpen,
|
|
76
|
+
onConnectionOpen = _ref$onConnectionOpen === void 0 ? function () {} : _ref$onConnectionOpen,
|
|
77
|
+
_ref$onConnetionClose = _ref.onConnetionClose,
|
|
78
|
+
onConnetionClose = _ref$onConnetionClose === void 0 ? function () {} : _ref$onConnetionClose,
|
|
79
|
+
_ref$onSwitchMeeting = _ref.onSwitchMeeting,
|
|
80
|
+
onSwitchMeeting = _ref$onSwitchMeeting === void 0 ? function () {} : _ref$onSwitchMeeting,
|
|
81
|
+
_ref$onError = _ref.onError,
|
|
82
|
+
onError = _ref$onError === void 0 ? function () {} : _ref$onError;
|
|
71
83
|
|
|
72
84
|
useEffect(function () {
|
|
73
85
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
@@ -89,6 +101,10 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
89
101
|
eventEmitter.on(events['webcam-requested'], onWebcamRequested);
|
|
90
102
|
eventEmitter.on(events['mic-requested'], onMicRequested);
|
|
91
103
|
eventEmitter.on(events['pin-state-changed'], onPinStateChanged);
|
|
104
|
+
eventEmitter.on(events['connection-open'], onConnectionOpen);
|
|
105
|
+
eventEmitter.on(events['connection-close'], onConnetionClose);
|
|
106
|
+
eventEmitter.on(events['switch-meeting'], onSwitchMeeting);
|
|
107
|
+
eventEmitter.on(events['error'], onError);
|
|
92
108
|
return function () {
|
|
93
109
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
94
110
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
@@ -109,6 +125,10 @@ var useMeeting = function useMeeting(_temp) {
|
|
|
109
125
|
eventEmitter.off(events['webcam-requested'], onWebcamRequested);
|
|
110
126
|
eventEmitter.off(events['mic-requested'], onMicRequested);
|
|
111
127
|
eventEmitter.off(events['pin-state-changed'], onPinStateChanged);
|
|
128
|
+
eventEmitter.off(events['connection-open'], onConnectionOpen);
|
|
129
|
+
eventEmitter.off(events['connection-close'], onConnetionClose);
|
|
130
|
+
eventEmitter.off(events['switch-meeting'], onSwitchMeeting);
|
|
131
|
+
eventEmitter.off(events['error'], onError);
|
|
112
132
|
};
|
|
113
133
|
}, []);
|
|
114
134
|
return useContext(MeetingProviderContex);
|
|
@@ -152,7 +172,15 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
152
172
|
_ref2$onMicRequested = _ref2.onMicRequested,
|
|
153
173
|
onMicRequested = _ref2$onMicRequested === void 0 ? function () {} : _ref2$onMicRequested,
|
|
154
174
|
_ref2$onPinStateChang = _ref2.onPinStateChanged,
|
|
155
|
-
onPinStateChanged = _ref2$onPinStateChang === void 0 ? function () {} : _ref2$onPinStateChang
|
|
175
|
+
onPinStateChanged = _ref2$onPinStateChang === void 0 ? function () {} : _ref2$onPinStateChang,
|
|
176
|
+
_ref2$onConnectionOpe = _ref2.onConnectionOpen,
|
|
177
|
+
onConnectionOpen = _ref2$onConnectionOpe === void 0 ? function () {} : _ref2$onConnectionOpe,
|
|
178
|
+
_ref2$onConnetionClos = _ref2.onConnetionClose,
|
|
179
|
+
onConnetionClose = _ref2$onConnetionClos === void 0 ? function () {} : _ref2$onConnetionClos,
|
|
180
|
+
_ref2$onSwitchMeeting = _ref2.onSwitchMeeting,
|
|
181
|
+
onSwitchMeeting = _ref2$onSwitchMeeting === void 0 ? function () {} : _ref2$onSwitchMeeting,
|
|
182
|
+
_ref2$onError = _ref2.onError,
|
|
183
|
+
onError = _ref2$onError === void 0 ? function () {} : _ref2$onError;
|
|
156
184
|
useEffect(function () {
|
|
157
185
|
eventEmitter.on(events['participant-joined'], onParticipantJoined);
|
|
158
186
|
eventEmitter.on(events['participant-left'], onParticipantLeft);
|
|
@@ -173,6 +201,10 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
173
201
|
eventEmitter.on(events['webcam-requested'], onWebcamRequested);
|
|
174
202
|
eventEmitter.on(events['mic-requested'], onMicRequested);
|
|
175
203
|
eventEmitter.on(events['pin-state-changed'], onPinStateChanged);
|
|
204
|
+
eventEmitter.on(events['connection-open'], onConnectionOpen);
|
|
205
|
+
eventEmitter.on(events['connection-close'], onConnetionClose);
|
|
206
|
+
eventEmitter.on(events['switch-meeting'], onSwitchMeeting);
|
|
207
|
+
eventEmitter.on(events['error'], onError);
|
|
176
208
|
return function () {
|
|
177
209
|
eventEmitter.off(events['participant-joined'], onParticipantJoined);
|
|
178
210
|
eventEmitter.off(events['participant-left'], onParticipantLeft);
|
|
@@ -193,6 +225,10 @@ var MeetingConsumer = function MeetingConsumer(_ref2) {
|
|
|
193
225
|
eventEmitter.off(events['webcam-requested'], onWebcamRequested);
|
|
194
226
|
eventEmitter.off(events['mic-requested'], onMicRequested);
|
|
195
227
|
eventEmitter.off(events['pin-state-changed'], onPinStateChanged);
|
|
228
|
+
eventEmitter.off(events['connection-open'], onConnectionOpen);
|
|
229
|
+
eventEmitter.off(events['connection-close'], onConnetionClose);
|
|
230
|
+
eventEmitter.off(events['switch-meeting'], onSwitchMeeting);
|
|
231
|
+
eventEmitter.off(events['error'], onError);
|
|
196
232
|
};
|
|
197
233
|
}, []);
|
|
198
234
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MeetingProviderContex.Consumer, null, children));
|
|
@@ -202,7 +238,8 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
202
238
|
var children = _ref.children,
|
|
203
239
|
config = _ref.config,
|
|
204
240
|
token = _ref.token,
|
|
205
|
-
joinWithoutUserInteraction = _ref.joinWithoutUserInteraction
|
|
241
|
+
joinWithoutUserInteraction = _ref.joinWithoutUserInteraction,
|
|
242
|
+
_reinitialiseMeetingOnConfigChange = _ref.reinitialiseMeetingOnConfigChange;
|
|
206
243
|
|
|
207
244
|
var _useState = useState(null),
|
|
208
245
|
meeting = _useState[0],
|
|
@@ -256,11 +293,21 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
256
293
|
isLiveStreaming = _useState13[0],
|
|
257
294
|
setIsLiveStreaming = _useState13[1];
|
|
258
295
|
|
|
296
|
+
var _useState14 = useState(new Map()),
|
|
297
|
+
connections = _useState14[0],
|
|
298
|
+
setConnections = _useState14[1];
|
|
299
|
+
|
|
259
300
|
var meetingRef = useRef();
|
|
260
301
|
var localMicOnRef = useRef();
|
|
261
302
|
var localWebcamOnRef = useRef();
|
|
262
303
|
var localScreenShareOnRef = useRef();
|
|
263
304
|
var isRecordingRef = useRef();
|
|
305
|
+
var configRef = useRef(config);
|
|
306
|
+
var tokenRef = useRef(token);
|
|
307
|
+
var joinedOnFirstRender = useRef(false);
|
|
308
|
+
var reinitialiseMeetingOnConfigChange = useMemo(function () {
|
|
309
|
+
return _reinitialiseMeetingOnConfigChange;
|
|
310
|
+
}, []);
|
|
264
311
|
useEffect(function () {
|
|
265
312
|
meetingRef.current = meeting;
|
|
266
313
|
}, [meeting]);
|
|
@@ -276,6 +323,12 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
276
323
|
useEffect(function () {
|
|
277
324
|
isRecordingRef.current = isRecording;
|
|
278
325
|
}, [isRecording]);
|
|
326
|
+
useEffect(function () {
|
|
327
|
+
configRef.current = config;
|
|
328
|
+
}, [config]);
|
|
329
|
+
useEffect(function () {
|
|
330
|
+
tokenRef.current = token;
|
|
331
|
+
}, [token]);
|
|
279
332
|
|
|
280
333
|
var resetStates = function resetStates() {
|
|
281
334
|
setMeeting(null);
|
|
@@ -291,6 +344,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
291
344
|
setIsLiveStreaming(false);
|
|
292
345
|
setParticipants(new Map());
|
|
293
346
|
setPinnedParticipants(new Map());
|
|
347
|
+
setConnections(new Map());
|
|
294
348
|
};
|
|
295
349
|
|
|
296
350
|
var _handle_participant_joined = function _handle_participant_joined(participant) {
|
|
@@ -401,6 +455,10 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
401
455
|
};
|
|
402
456
|
|
|
403
457
|
var _handle_meeting_joined = function _handle_meeting_joined(data) {
|
|
458
|
+
joinedOnFirstRender.current = true;
|
|
459
|
+
setMessages(function (s) {
|
|
460
|
+
return [].concat(s, data.messages);
|
|
461
|
+
});
|
|
404
462
|
eventEmitter.emit(events['meeting-joined'], data);
|
|
405
463
|
};
|
|
406
464
|
|
|
@@ -430,6 +488,11 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
430
488
|
meeting.off('video-seeked', _handle_video_seeked);
|
|
431
489
|
meeting.off('webcam-requested', _handle_webcam_requested);
|
|
432
490
|
meeting.off('mic-requested', _handle_mic_requested);
|
|
491
|
+
meeting.off('pin-state-changed', _handle_pin_state_changed);
|
|
492
|
+
meeting.off('connection-open', _handle_connection_open);
|
|
493
|
+
meeting.off('connection-close', _handle_connection_close);
|
|
494
|
+
meeting.off('switch-meeting', _handle_switch_meeting);
|
|
495
|
+
meeting.off('error', _handle_error);
|
|
433
496
|
}
|
|
434
497
|
|
|
435
498
|
if (typeof (meeting === null || meeting === void 0 ? void 0 : (_meeting$localPartici = meeting.localParticipant) === null || _meeting$localPartici === void 0 ? void 0 : _meeting$localPartici.off) === 'function') {
|
|
@@ -462,8 +525,34 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
462
525
|
});
|
|
463
526
|
};
|
|
464
527
|
|
|
528
|
+
var _handle_connection_open = function _handle_connection_open(connection) {
|
|
529
|
+
setConnections(function (s) {
|
|
530
|
+
s.set(connection.id, connection);
|
|
531
|
+
var connectionsToSet = new Map(s);
|
|
532
|
+
return connectionsToSet;
|
|
533
|
+
});
|
|
534
|
+
eventEmitter.emit(events['connection-open'], connection);
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
var _handle_connection_close = function _handle_connection_close(connectionId) {
|
|
538
|
+
setConnections(function (s) {
|
|
539
|
+
s["delete"](connectionId);
|
|
540
|
+
var newConnections = new Map(s);
|
|
541
|
+
return newConnections;
|
|
542
|
+
});
|
|
543
|
+
eventEmitter.emit(events['connection-close'], connectionId);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
var _handle_error = function _handle_error(data) {
|
|
547
|
+
eventEmitter.emit(events['error'], data);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
var _handle_switch_meeting = function _handle_switch_meeting(d) {
|
|
551
|
+
eventEmitter.emit(events['switch-meeting'], d);
|
|
552
|
+
};
|
|
553
|
+
|
|
465
554
|
var join = function join() {
|
|
466
|
-
var meeting =
|
|
555
|
+
var meeting = VideoSDK && VideoSDK.initMeeting(configRef.current);
|
|
467
556
|
setMeeting(meeting);
|
|
468
557
|
var localParticipant = meeting.localParticipant,
|
|
469
558
|
participants = meeting.participants;
|
|
@@ -489,6 +578,10 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
489
578
|
meeting.on('webcam-requested', _handle_webcam_requested);
|
|
490
579
|
meeting.on('mic-requested', _handle_mic_requested);
|
|
491
580
|
meeting.on('pin-state-changed', _handle_pin_state_changed);
|
|
581
|
+
meeting.on('connection-open', _handle_connection_open);
|
|
582
|
+
meeting.on('connection-close', _handle_connection_close);
|
|
583
|
+
meeting.on('switch-meeting', _handle_switch_meeting);
|
|
584
|
+
meeting.on('error', _handle_error);
|
|
492
585
|
meeting.localParticipant.on('stream-enabled', _handle_localParticipant_stream_enabled);
|
|
493
586
|
meeting.localParticipant.on('stream-disabled', _handle_localParticipant_stream_disabled);
|
|
494
587
|
meeting.join();
|
|
@@ -510,11 +603,11 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
510
603
|
}
|
|
511
604
|
};
|
|
512
605
|
|
|
513
|
-
var startRecording = function startRecording(webhookUrl) {
|
|
606
|
+
var startRecording = function startRecording(webhookUrl, awsDirPath) {
|
|
514
607
|
var meeting = meetingRef.current;
|
|
515
608
|
|
|
516
609
|
if (meeting) {
|
|
517
|
-
meeting.startRecording(webhookUrl);
|
|
610
|
+
meeting.startRecording(webhookUrl, awsDirPath);
|
|
518
611
|
}
|
|
519
612
|
};
|
|
520
613
|
|
|
@@ -731,8 +824,30 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
731
824
|
}
|
|
732
825
|
};
|
|
733
826
|
|
|
827
|
+
var connectTo = function connectTo(_ref6) {
|
|
828
|
+
var meetingId = _ref6.meetingId,
|
|
829
|
+
payload = _ref6.payload;
|
|
830
|
+
|
|
831
|
+
try {
|
|
832
|
+
var _meeting3 = meetingRef.current;
|
|
833
|
+
|
|
834
|
+
var _temp2 = function () {
|
|
835
|
+
if (_meeting3) {
|
|
836
|
+
return Promise.resolve(_meeting3.connectTo({
|
|
837
|
+
meetingId: meetingId,
|
|
838
|
+
payload: payload
|
|
839
|
+
})).then(function () {});
|
|
840
|
+
}
|
|
841
|
+
}();
|
|
842
|
+
|
|
843
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
844
|
+
} catch (e) {
|
|
845
|
+
return Promise.reject(e);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
734
849
|
var initSDK = function initSDK() {
|
|
735
|
-
|
|
850
|
+
VideoSDK.config(tokenRef.current);
|
|
736
851
|
|
|
737
852
|
if (joinWithoutUserInteraction) {
|
|
738
853
|
join();
|
|
@@ -742,9 +857,16 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
742
857
|
useEffect(function () {
|
|
743
858
|
initSDK();
|
|
744
859
|
}, []);
|
|
860
|
+
useEffect(function () {
|
|
861
|
+
if (reinitialiseMeetingOnConfigChange && joinedOnFirstRender.current) {
|
|
862
|
+
leave();
|
|
863
|
+
initSDK();
|
|
864
|
+
!joinWithoutUserInteraction && join();
|
|
865
|
+
}
|
|
866
|
+
}, [config.meetingId, token, reinitialiseMeetingOnConfigChange]);
|
|
745
867
|
return /*#__PURE__*/React.createElement(MeetingProviderContex.Provider, {
|
|
746
868
|
value: {
|
|
747
|
-
meetingId:
|
|
869
|
+
meetingId: meeting === null || meeting === void 0 ? void 0 : meeting.id,
|
|
748
870
|
meeting: meeting,
|
|
749
871
|
localParticipant: localParticipant,
|
|
750
872
|
mainParticipant: mainParticipant,
|
|
@@ -758,6 +880,7 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
758
880
|
isRecording: isRecording,
|
|
759
881
|
isLiveStreaming: isLiveStreaming,
|
|
760
882
|
pinnedParticipants: pinnedParticipants,
|
|
883
|
+
connections: connections,
|
|
761
884
|
join: join,
|
|
762
885
|
leave: leave,
|
|
763
886
|
end: end,
|
|
@@ -784,7 +907,8 @@ var MeetingProvider = function MeetingProvider(_ref) {
|
|
|
784
907
|
pauseVideo: pauseVideo,
|
|
785
908
|
seekVideo: seekVideo,
|
|
786
909
|
startLivestream: startLivestream,
|
|
787
|
-
stopLivestream: stopLivestream
|
|
910
|
+
stopLivestream: stopLivestream,
|
|
911
|
+
connectTo: connectTo
|
|
788
912
|
}
|
|
789
913
|
}, children);
|
|
790
914
|
};
|
|
@@ -911,6 +1035,10 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
911
1035
|
participant === null || participant === void 0 ? void 0 : participant.unpin(data);
|
|
912
1036
|
};
|
|
913
1037
|
|
|
1038
|
+
var switchTo = function switchTo(data) {
|
|
1039
|
+
return Promise.resolve(participant === null || participant === void 0 ? void 0 : participant.switchTo(data)).then(function () {});
|
|
1040
|
+
};
|
|
1041
|
+
|
|
914
1042
|
useEffect(function () {
|
|
915
1043
|
var streams = participant === null || participant === void 0 ? void 0 : participant.streams;
|
|
916
1044
|
|
|
@@ -946,9 +1074,94 @@ var useParticipant = function useParticipant(participantId, _temp) {
|
|
|
946
1074
|
enableWebcam: enableWebcam,
|
|
947
1075
|
disableWebcam: disableWebcam,
|
|
948
1076
|
pin: pin,
|
|
949
|
-
unpin: unpin
|
|
1077
|
+
unpin: unpin,
|
|
1078
|
+
switchTo: switchTo
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
var useConnection = function useConnection(connectionId, _temp) {
|
|
1083
|
+
var _ref = _temp === void 0 ? {
|
|
1084
|
+
onMeeting: {
|
|
1085
|
+
onParticipantJoined: function onParticipantJoined() {},
|
|
1086
|
+
onParticipantLeft: function onParticipantLeft() {},
|
|
1087
|
+
onChatMessage: function onChatMessage() {}
|
|
1088
|
+
}
|
|
1089
|
+
} : _temp,
|
|
1090
|
+
onMeeting = _ref.onMeeting;
|
|
1091
|
+
|
|
1092
|
+
var onParticipantJoined = onMeeting === null || onMeeting === void 0 ? void 0 : onMeeting.onParticipantJoined;
|
|
1093
|
+
var onParticipantLeft = onMeeting === null || onMeeting === void 0 ? void 0 : onMeeting.onParticipantLeft;
|
|
1094
|
+
var onChatMessage = onMeeting === null || onMeeting === void 0 ? void 0 : onMeeting.onChatMessage;
|
|
1095
|
+
var meeting = useMeeting();
|
|
1096
|
+
|
|
1097
|
+
var _useMemo = useMemo(function () {
|
|
1098
|
+
var connection = meeting === null || meeting === void 0 ? void 0 : meeting.connections.get(connectionId);
|
|
1099
|
+
|
|
1100
|
+
if (!connection) {
|
|
1101
|
+
throw new Error('connectionId not found');
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
var connectionParticipants = new Map(connection.meeting.participants);
|
|
1105
|
+
return {
|
|
1106
|
+
connection: connection,
|
|
1107
|
+
connectionParticipants: connectionParticipants
|
|
1108
|
+
};
|
|
1109
|
+
}, [meeting]),
|
|
1110
|
+
connection = _useMemo.connection,
|
|
1111
|
+
connectionParticipants = _useMemo.connectionParticipants;
|
|
1112
|
+
|
|
1113
|
+
var _useState = useState(new Map(connectionParticipants)),
|
|
1114
|
+
_connectionParticipants = _useState[0],
|
|
1115
|
+
setConnectionParticipants = _useState[1];
|
|
1116
|
+
|
|
1117
|
+
var _handleParticipantJoined = function _handleParticipantJoined(participant) {
|
|
1118
|
+
setConnectionParticipants(function (s) {
|
|
1119
|
+
s.set(participant.id, participant);
|
|
1120
|
+
var participantsToSet = new Map(s);
|
|
1121
|
+
return participantsToSet;
|
|
1122
|
+
});
|
|
1123
|
+
onParticipantJoined(participant);
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
var _handleParticipantLeft = function _handleParticipantLeft(participantId) {
|
|
1127
|
+
setConnectionParticipants(function (s) {
|
|
1128
|
+
s["delete"](participantId);
|
|
1129
|
+
var newParticipants = new Map(s);
|
|
1130
|
+
return newParticipants;
|
|
1131
|
+
});
|
|
1132
|
+
onParticipantLeft(participantId);
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
var _handleChatMessage = function _handleChatMessage(data) {
|
|
1136
|
+
onChatMessage(data);
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
useEffect(function () {
|
|
1140
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.on('participant-joined', _handleParticipantJoined);
|
|
1141
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.on('participant-left', _handleParticipantLeft);
|
|
1142
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.on('chat-message', _handleChatMessage);
|
|
1143
|
+
return function () {
|
|
1144
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.off('participant-joined', _handleParticipantJoined);
|
|
1145
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.off('participant-left', _handleParticipantLeft);
|
|
1146
|
+
connection === null || connection === void 0 ? void 0 : connection.meeting.off('chat-message', _handleChatMessage);
|
|
1147
|
+
};
|
|
1148
|
+
}, [connection]);
|
|
1149
|
+
return {
|
|
1150
|
+
connection: {
|
|
1151
|
+
id: connection.id,
|
|
1152
|
+
close: connection.close,
|
|
1153
|
+
payload: connection.payload,
|
|
1154
|
+
meeting: {
|
|
1155
|
+
id: connection.meeting.id,
|
|
1156
|
+
sendChatMessage: connection.meeting.sendChatMessage,
|
|
1157
|
+
end: connection.meeting.end,
|
|
1158
|
+
participants: _connectionParticipants
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
950
1161
|
};
|
|
951
1162
|
};
|
|
952
1163
|
|
|
953
|
-
|
|
1164
|
+
var Constants = VideoSDK.Constants;
|
|
1165
|
+
|
|
1166
|
+
export { Constants, MeetingConsumer, MeetingProvider, useConnection, useMeeting, useParticipant };
|
|
954
1167
|
//# sourceMappingURL=index.modern.js.map
|