@whereby.com/browser-sdk 2.0.0-alpha7 → 2.0.0-alpha9
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/lib.cjs.js +211 -64
- package/dist/lib.esm.js +211 -64
- package/dist/types.d.ts +48 -5
- package/dist/{v2-alpha7.js → v2-alpha9.js} +2 -2
- package/package.json +1 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -130,7 +130,7 @@ heresy.define("WherebyEmbed", {
|
|
|
130
130
|
if (!subdomain)
|
|
131
131
|
return this.html `Whereby: Missing subdomain attr.`;
|
|
132
132
|
const url = new URL(room, `https://${subdomain}.whereby.com`);
|
|
133
|
-
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-
|
|
133
|
+
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha9", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
|
|
134
134
|
// add to URL if set in any way
|
|
135
135
|
(o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
|
|
136
136
|
if (!url.searchParams.has(k) && typeof v === "string") {
|
|
@@ -5277,7 +5277,7 @@ class LocalParticipant extends RoomParticipant {
|
|
|
5277
5277
|
}
|
|
5278
5278
|
}
|
|
5279
5279
|
|
|
5280
|
-
const API_BASE_URL = "https://api.
|
|
5280
|
+
const API_BASE_URL = "https://api.whereby.dev";
|
|
5281
5281
|
const SIGNAL_BASE_URL = "wss://signal.appearin.net";
|
|
5282
5282
|
const NON_PERSON_ROLES = ["recorder", "streamer"];
|
|
5283
5283
|
function createSocket() {
|
|
@@ -5290,6 +5290,7 @@ function createSocket() {
|
|
|
5290
5290
|
reconnectionDelay: 5000,
|
|
5291
5291
|
reconnectionDelayMax: 30000,
|
|
5292
5292
|
timeout: 10000,
|
|
5293
|
+
withCredentials: true,
|
|
5293
5294
|
};
|
|
5294
5295
|
return new ServerSocket(SOCKET_HOST, socketConf);
|
|
5295
5296
|
}
|
|
@@ -5298,13 +5299,17 @@ const noop = () => {
|
|
|
5298
5299
|
};
|
|
5299
5300
|
const TypedEventTarget = EventTarget;
|
|
5300
5301
|
class RoomConnection extends TypedEventTarget {
|
|
5301
|
-
constructor(roomUrl, { displayName, localMediaConstraints, logger,
|
|
5302
|
+
constructor(roomUrl, { displayName, localMedia, localMediaConstraints, logger, roomKey }) {
|
|
5302
5303
|
super();
|
|
5303
5304
|
this.localParticipant = null;
|
|
5304
5305
|
this.remoteParticipants = [];
|
|
5305
|
-
this.roomConnectionState = "";
|
|
5306
5306
|
this._ownsLocalMedia = false;
|
|
5307
|
+
this.organizationId = "";
|
|
5308
|
+
this.roomConnectionStatus = "";
|
|
5307
5309
|
this.roomUrl = new URL(roomUrl); // Throw if invalid Whereby room url
|
|
5310
|
+
const searchParams = new URLSearchParams(this.roomUrl.search);
|
|
5311
|
+
this._roomKey = roomKey || searchParams.get("roomKey");
|
|
5312
|
+
this.roomName = this.roomUrl.pathname;
|
|
5308
5313
|
this.logger = logger || {
|
|
5309
5314
|
debug: noop,
|
|
5310
5315
|
error: noop,
|
|
@@ -5325,6 +5330,7 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5325
5330
|
else {
|
|
5326
5331
|
throw new Error("Missing constraints");
|
|
5327
5332
|
}
|
|
5333
|
+
// Set up services
|
|
5328
5334
|
this.credentialsService = CredentialsService.create({ baseUrl: API_BASE_URL });
|
|
5329
5335
|
this.apiClient = new ApiClient({
|
|
5330
5336
|
fetchDeviceCredentials: this.credentialsService.getCredentials.bind(this.credentialsService),
|
|
@@ -5346,10 +5352,15 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5346
5352
|
// Create signal socket and set up event listeners
|
|
5347
5353
|
this.signalSocket = createSocket();
|
|
5348
5354
|
this.signalSocket.on("new_client", this._handleNewClient.bind(this));
|
|
5355
|
+
this.signalSocket.on("chat_message", this._handleNewChatMessage.bind(this));
|
|
5349
5356
|
this.signalSocket.on("client_left", this._handleClientLeft.bind(this));
|
|
5350
5357
|
this.signalSocket.on("audio_enabled", this._handleClientAudioEnabled.bind(this));
|
|
5351
5358
|
this.signalSocket.on("video_enabled", this._handleClientVideoEnabled.bind(this));
|
|
5352
5359
|
this.signalSocket.on("client_metadata_received", this._handleClientMetadataReceived.bind(this));
|
|
5360
|
+
this.signalSocket.on("knock_handled", this._handleKnockHandled.bind(this));
|
|
5361
|
+
this.signalSocket.on("knocker_left", this._handleKnockerLeft.bind(this));
|
|
5362
|
+
this.signalSocket.on("room_joined", this._handleRoomJoined.bind(this));
|
|
5363
|
+
this.signalSocket.on("room_knocked", this._handleRoomKnocked.bind(this));
|
|
5353
5364
|
// Set up local media listeners
|
|
5354
5365
|
this.localMedia.addEventListener("camera_enabled", (e) => {
|
|
5355
5366
|
const { enabled } = e.detail;
|
|
@@ -5360,6 +5371,12 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5360
5371
|
this.signalSocket.emit("enable_audio", { enabled });
|
|
5361
5372
|
});
|
|
5362
5373
|
}
|
|
5374
|
+
get roomKey() {
|
|
5375
|
+
return this._roomKey;
|
|
5376
|
+
}
|
|
5377
|
+
_handleNewChatMessage(message) {
|
|
5378
|
+
this.dispatchEvent(new CustomEvent("chat_message", { detail: message }));
|
|
5379
|
+
}
|
|
5363
5380
|
_handleNewClient({ client }) {
|
|
5364
5381
|
if (NON_PERSON_ROLES.includes(client.role.roleName)) {
|
|
5365
5382
|
return;
|
|
@@ -5404,6 +5421,70 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5404
5421
|
detail: { participantId: remoteParticipant.id, displayName },
|
|
5405
5422
|
}));
|
|
5406
5423
|
}
|
|
5424
|
+
_handleKnockHandled(payload) {
|
|
5425
|
+
const { resolution } = payload;
|
|
5426
|
+
if (resolution === "accepted") {
|
|
5427
|
+
this.roomConnectionStatus = "accepted";
|
|
5428
|
+
this._roomKey = payload.metadata.roomKey;
|
|
5429
|
+
this._joinRoom();
|
|
5430
|
+
}
|
|
5431
|
+
else if (resolution === "rejected") {
|
|
5432
|
+
this.roomConnectionStatus = "rejected";
|
|
5433
|
+
this.dispatchEvent(new CustomEvent("room_connection_status_changed", {
|
|
5434
|
+
detail: {
|
|
5435
|
+
roomConnectionStatus: this.roomConnectionStatus,
|
|
5436
|
+
},
|
|
5437
|
+
}));
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
_handleKnockerLeft(payload) {
|
|
5441
|
+
const { clientId } = payload;
|
|
5442
|
+
this.dispatchEvent(new CustomEvent("waiting_participant_left", {
|
|
5443
|
+
detail: { participantId: clientId },
|
|
5444
|
+
}));
|
|
5445
|
+
}
|
|
5446
|
+
_handleRoomJoined(event) {
|
|
5447
|
+
const { error, isLocked, room, selfId } = event;
|
|
5448
|
+
if (error === "room_locked" && isLocked) {
|
|
5449
|
+
this.roomConnectionStatus = "room_locked";
|
|
5450
|
+
this.dispatchEvent(new CustomEvent("room_connection_status_changed", {
|
|
5451
|
+
detail: {
|
|
5452
|
+
roomConnectionStatus: this.roomConnectionStatus,
|
|
5453
|
+
},
|
|
5454
|
+
}));
|
|
5455
|
+
return;
|
|
5456
|
+
}
|
|
5457
|
+
// Check if we have an error
|
|
5458
|
+
// Check if it is a room joined error
|
|
5459
|
+
// Set state to connect_failed_locked
|
|
5460
|
+
// Set state to connect_failed_no_host
|
|
5461
|
+
if (room) {
|
|
5462
|
+
const { clients, knockers } = room;
|
|
5463
|
+
const localClient = clients.find((c) => c.id === selfId);
|
|
5464
|
+
if (!localClient)
|
|
5465
|
+
throw new Error("Missing local client");
|
|
5466
|
+
this.localParticipant = new LocalParticipant(Object.assign(Object.assign({}, localClient), { stream: this.localMedia.stream || undefined }));
|
|
5467
|
+
this.remoteParticipants = clients
|
|
5468
|
+
.filter((c) => c.id !== selfId)
|
|
5469
|
+
.map((c) => new RemoteParticipant(Object.assign(Object.assign({}, c), { newJoiner: false })));
|
|
5470
|
+
this.roomConnectionStatus = "connected";
|
|
5471
|
+
this.dispatchEvent(new CustomEvent("room_joined", {
|
|
5472
|
+
detail: {
|
|
5473
|
+
localParticipant: this.localParticipant,
|
|
5474
|
+
remoteParticipants: this.remoteParticipants,
|
|
5475
|
+
waitingParticipants: knockers.map((knocker) => {
|
|
5476
|
+
return { id: knocker.clientId, displayName: knocker.displayName };
|
|
5477
|
+
}),
|
|
5478
|
+
},
|
|
5479
|
+
}));
|
|
5480
|
+
}
|
|
5481
|
+
}
|
|
5482
|
+
_handleRoomKnocked(event) {
|
|
5483
|
+
const { clientId, displayName } = event;
|
|
5484
|
+
this.dispatchEvent(new CustomEvent("waiting_participant_joined", {
|
|
5485
|
+
detail: { participantId: clientId, displayName },
|
|
5486
|
+
}));
|
|
5487
|
+
}
|
|
5407
5488
|
_handleRtcEvent(eventName, data) {
|
|
5408
5489
|
if (eventName === "rtc_manager_created") {
|
|
5409
5490
|
return this._handleRtcManagerCreated(data);
|
|
@@ -5422,6 +5503,9 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5422
5503
|
if (this.localMedia.stream) {
|
|
5423
5504
|
(_a = this.rtcManager) === null || _a === void 0 ? void 0 : _a.addNewStream("0", this.localMedia.stream, !this.localMedia.isMicrophoneEnabled(), !this.localMedia.isCameraEnabled());
|
|
5424
5505
|
}
|
|
5506
|
+
if (this.remoteParticipants.length) {
|
|
5507
|
+
this._handleAcceptStreams(this.remoteParticipants);
|
|
5508
|
+
}
|
|
5425
5509
|
}
|
|
5426
5510
|
_handleAcceptStreams(remoteParticipants) {
|
|
5427
5511
|
var _a, _b;
|
|
@@ -5479,14 +5563,43 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5479
5563
|
}
|
|
5480
5564
|
this.dispatchEvent(new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } }));
|
|
5481
5565
|
}
|
|
5566
|
+
_joinRoom() {
|
|
5567
|
+
this.signalSocket.emit("join_room", {
|
|
5568
|
+
avatarUrl: null,
|
|
5569
|
+
config: {
|
|
5570
|
+
isAudioEnabled: this.localMedia.isMicrophoneEnabled(),
|
|
5571
|
+
isVideoEnabled: this.localMedia.isCameraEnabled(),
|
|
5572
|
+
},
|
|
5573
|
+
deviceCapabilities: { canScreenshare: true },
|
|
5574
|
+
displayName: this.displayName,
|
|
5575
|
+
isCoLocated: false,
|
|
5576
|
+
isDevicePermissionDenied: false,
|
|
5577
|
+
kickFromOtherRooms: false,
|
|
5578
|
+
organizationId: this.organizationId,
|
|
5579
|
+
roomKey: this.roomKey,
|
|
5580
|
+
roomName: this.roomName,
|
|
5581
|
+
selfId: "",
|
|
5582
|
+
userAgent: `browser-sdk:${sdkVersion }`,
|
|
5583
|
+
});
|
|
5584
|
+
}
|
|
5482
5585
|
join() {
|
|
5483
5586
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
5484
|
-
if (["connected", "connecting"].includes(this.
|
|
5485
|
-
console.warn(`Trying to join room state is ${this.
|
|
5587
|
+
if (["connected", "connecting"].includes(this.roomConnectionStatus)) {
|
|
5588
|
+
console.warn(`Trying to join when room state is already ${this.roomConnectionStatus}`);
|
|
5486
5589
|
return;
|
|
5487
5590
|
}
|
|
5488
5591
|
this.logger.log("Joining room");
|
|
5489
|
-
this.
|
|
5592
|
+
this.roomConnectionStatus = "connecting";
|
|
5593
|
+
this.dispatchEvent(new CustomEvent("room_connection_status_changed", {
|
|
5594
|
+
detail: {
|
|
5595
|
+
roomConnectionStatus: this.roomConnectionStatus,
|
|
5596
|
+
},
|
|
5597
|
+
}));
|
|
5598
|
+
const organization = yield this.organizationServiceCache.fetchOrganization();
|
|
5599
|
+
if (!organization) {
|
|
5600
|
+
throw new Error("Invalid room url");
|
|
5601
|
+
}
|
|
5602
|
+
this.organizationId = organization.organizationId;
|
|
5490
5603
|
if (this._ownsLocalMedia) {
|
|
5491
5604
|
yield this.localMedia.start();
|
|
5492
5605
|
}
|
|
@@ -5515,60 +5628,32 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5515
5628
|
simulcastScreenshareOn: false,
|
|
5516
5629
|
},
|
|
5517
5630
|
});
|
|
5518
|
-
const organization = yield this.organizationServiceCache.fetchOrganization();
|
|
5519
|
-
if (!organization) {
|
|
5520
|
-
throw new Error("Invalid room url");
|
|
5521
|
-
}
|
|
5522
5631
|
// Identify device on signal connection
|
|
5523
5632
|
const deviceCredentials = yield this.credentialsService.getCredentials();
|
|
5524
|
-
this.
|
|
5525
|
-
|
|
5526
|
-
this.signalSocket.on("connect", () => {
|
|
5527
|
-
this.logger.log("Connected to signal socket");
|
|
5528
|
-
this.signalSocket.emit("identify_device", { deviceCredentials });
|
|
5529
|
-
});
|
|
5633
|
+
this.logger.log("Connected to signal socket");
|
|
5634
|
+
this.signalSocket.emit("identify_device", { deviceCredentials });
|
|
5530
5635
|
this.signalSocket.once("device_identified", () => {
|
|
5531
|
-
this.
|
|
5532
|
-
avatarUrl: null,
|
|
5533
|
-
config: {
|
|
5534
|
-
isAudioEnabled: this.localMedia.isMicrophoneEnabled(),
|
|
5535
|
-
isVideoEnabled: this.localMedia.isCameraEnabled(),
|
|
5536
|
-
},
|
|
5537
|
-
deviceCapabilities: { canScreenshare: true },
|
|
5538
|
-
displayName: this.displayName,
|
|
5539
|
-
isCoLocated: false,
|
|
5540
|
-
isDevicePermissionDenied: false,
|
|
5541
|
-
kickFromOtherRooms: false,
|
|
5542
|
-
organizationId: organization.organizationId,
|
|
5543
|
-
roomKey: null,
|
|
5544
|
-
roomName: this.roomUrl.pathname,
|
|
5545
|
-
selfId: "",
|
|
5546
|
-
userAgent: `browser-sdk:${sdkVersion }`,
|
|
5547
|
-
});
|
|
5548
|
-
});
|
|
5549
|
-
this.signalSocket.once("room_joined", (res) => {
|
|
5550
|
-
const { selfId, room: { clients }, } = res;
|
|
5551
|
-
const localClient = clients.find((c) => c.id === selfId);
|
|
5552
|
-
if (!localClient)
|
|
5553
|
-
throw new Error("Missing local client");
|
|
5554
|
-
this.localParticipant = new LocalParticipant(Object.assign(Object.assign({}, localClient), { stream: this.localMedia.stream || undefined }));
|
|
5555
|
-
this.remoteParticipants = clients
|
|
5556
|
-
.filter((c) => c.id !== selfId)
|
|
5557
|
-
.map((c) => new RemoteParticipant(Object.assign(Object.assign({}, c), { newJoiner: false })));
|
|
5558
|
-
// Accept remote streams if RTC manager has been initialized
|
|
5559
|
-
if (this.rtcManager) {
|
|
5560
|
-
this._handleAcceptStreams(this.remoteParticipants);
|
|
5561
|
-
}
|
|
5562
|
-
this.roomConnectionState = "connected";
|
|
5563
|
-
this.dispatchEvent(new CustomEvent("room_joined", {
|
|
5564
|
-
detail: {
|
|
5565
|
-
localParticipant: this.localParticipant,
|
|
5566
|
-
remoteParticipants: this.remoteParticipants,
|
|
5567
|
-
},
|
|
5568
|
-
}));
|
|
5636
|
+
this._joinRoom();
|
|
5569
5637
|
});
|
|
5570
5638
|
});
|
|
5571
5639
|
}
|
|
5640
|
+
knock() {
|
|
5641
|
+
this.roomConnectionStatus = "knocking";
|
|
5642
|
+
this.dispatchEvent(new CustomEvent("room_connection_status_changed", {
|
|
5643
|
+
detail: {
|
|
5644
|
+
roomConnectionStatus: this.roomConnectionStatus,
|
|
5645
|
+
},
|
|
5646
|
+
}));
|
|
5647
|
+
this.signalSocket.emit("knock_room", {
|
|
5648
|
+
displayName: this.displayName,
|
|
5649
|
+
imageUrl: null,
|
|
5650
|
+
kickFromOtherRooms: true,
|
|
5651
|
+
liveVideo: false,
|
|
5652
|
+
organizationId: this.organizationId,
|
|
5653
|
+
roomKey: this._roomKey,
|
|
5654
|
+
roomName: this.roomName,
|
|
5655
|
+
});
|
|
5656
|
+
}
|
|
5572
5657
|
leave() {
|
|
5573
5658
|
return new Promise((resolve) => {
|
|
5574
5659
|
if (this._ownsLocalMedia) {
|
|
@@ -5593,6 +5678,11 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5593
5678
|
});
|
|
5594
5679
|
});
|
|
5595
5680
|
}
|
|
5681
|
+
sendChatMessage(text) {
|
|
5682
|
+
this.signalSocket.emit("chat_message", {
|
|
5683
|
+
text,
|
|
5684
|
+
});
|
|
5685
|
+
}
|
|
5596
5686
|
setDisplayName(displayName) {
|
|
5597
5687
|
this.signalSocket.emit("send_client_metadata", {
|
|
5598
5688
|
type: "UserData",
|
|
@@ -5601,12 +5691,30 @@ class RoomConnection extends TypedEventTarget {
|
|
|
5601
5691
|
},
|
|
5602
5692
|
});
|
|
5603
5693
|
}
|
|
5694
|
+
acceptWaitingParticipant(participantId) {
|
|
5695
|
+
this.signalSocket.emit("handle_knock", {
|
|
5696
|
+
action: "accept",
|
|
5697
|
+
clientId: participantId,
|
|
5698
|
+
response: {},
|
|
5699
|
+
});
|
|
5700
|
+
}
|
|
5701
|
+
rejectWaitingParticipant(participantId) {
|
|
5702
|
+
this.signalSocket.emit("handle_knock", {
|
|
5703
|
+
action: "reject",
|
|
5704
|
+
clientId: participantId,
|
|
5705
|
+
response: {},
|
|
5706
|
+
});
|
|
5707
|
+
}
|
|
5604
5708
|
}
|
|
5605
5709
|
|
|
5606
5710
|
const initialState = {
|
|
5711
|
+
chatMessages: [],
|
|
5712
|
+
roomConnectionStatus: "",
|
|
5607
5713
|
isJoining: false,
|
|
5608
5714
|
joinError: null,
|
|
5715
|
+
mostRecentChatMessage: null,
|
|
5609
5716
|
remoteParticipants: [],
|
|
5717
|
+
waitingParticipants: [],
|
|
5610
5718
|
};
|
|
5611
5719
|
function updateParticipant(remoteParticipants, participantId, updates) {
|
|
5612
5720
|
const existingParticipant = remoteParticipants.find((p) => p.id === participantId);
|
|
@@ -5622,8 +5730,12 @@ function updateParticipant(remoteParticipants, participantId, updates) {
|
|
|
5622
5730
|
}
|
|
5623
5731
|
function reducer(state, action) {
|
|
5624
5732
|
switch (action.type) {
|
|
5733
|
+
case "CHAT_MESSAGE":
|
|
5734
|
+
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, action.payload], mostRecentChatMessage: action.payload });
|
|
5625
5735
|
case "ROOM_JOINED":
|
|
5626
|
-
return Object.assign(Object.assign({}, state), { localParticipant: action.payload.localParticipant, remoteParticipants: action.payload.remoteParticipants, roomConnectionStatus: "connected" });
|
|
5736
|
+
return Object.assign(Object.assign({}, state), { localParticipant: action.payload.localParticipant, remoteParticipants: action.payload.remoteParticipants, waitingParticipants: action.payload.waitingParticipants, roomConnectionStatus: "connected" });
|
|
5737
|
+
case "ROOM_CONNECTION_STATUS_CHANGED":
|
|
5738
|
+
return Object.assign(Object.assign({}, state), { roomConnectionStatus: action.payload.roomConnectionStatus });
|
|
5627
5739
|
case "PARTICIPANT_AUDIO_ENABLED":
|
|
5628
5740
|
return Object.assign(Object.assign({}, state), { remoteParticipants: updateParticipant(state.remoteParticipants, action.payload.participantId, {
|
|
5629
5741
|
isAudioEnabled: action.payload.isAudioEnabled,
|
|
@@ -5648,6 +5760,13 @@ function reducer(state, action) {
|
|
|
5648
5760
|
if (!state.localParticipant)
|
|
5649
5761
|
return state;
|
|
5650
5762
|
return Object.assign(Object.assign({}, state), { localParticipant: Object.assign(Object.assign({}, state.localParticipant), { displayName: action.payload.displayName }) });
|
|
5763
|
+
case "WAITING_PARTICIPANT_JOINED":
|
|
5764
|
+
return Object.assign(Object.assign({}, state), { waitingParticipants: [
|
|
5765
|
+
...state.waitingParticipants,
|
|
5766
|
+
{ id: action.payload.participantId, displayName: action.payload.displayName },
|
|
5767
|
+
] });
|
|
5768
|
+
case "WAITING_PARTICIPANT_LEFT":
|
|
5769
|
+
return Object.assign(Object.assign({}, state), { waitingParticipants: state.waitingParticipants.filter((wp) => wp.id !== action.payload.participantId) });
|
|
5651
5770
|
default:
|
|
5652
5771
|
throw state;
|
|
5653
5772
|
}
|
|
@@ -5659,6 +5778,10 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5659
5778
|
});
|
|
5660
5779
|
const [state, dispatch] = React.useReducer(reducer, initialState);
|
|
5661
5780
|
React.useEffect(() => {
|
|
5781
|
+
roomConnection.addEventListener("chat_message", (e) => {
|
|
5782
|
+
const chatMessage = e.detail;
|
|
5783
|
+
dispatch({ type: "CHAT_MESSAGE", payload: chatMessage });
|
|
5784
|
+
});
|
|
5662
5785
|
roomConnection.addEventListener("participant_audio_enabled", (e) => {
|
|
5663
5786
|
const { participantId, isAudioEnabled } = e.detail;
|
|
5664
5787
|
dispatch({ type: "PARTICIPANT_AUDIO_ENABLED", payload: { participantId, isAudioEnabled } });
|
|
@@ -5675,9 +5798,13 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5675
5798
|
const { participantId, stream } = e.detail;
|
|
5676
5799
|
dispatch({ type: "PARTICIPANT_STREAM_ADDED", payload: { participantId, stream } });
|
|
5677
5800
|
});
|
|
5801
|
+
roomConnection.addEventListener("room_connection_status_changed", (e) => {
|
|
5802
|
+
const { roomConnectionStatus } = e.detail;
|
|
5803
|
+
dispatch({ type: "ROOM_CONNECTION_STATUS_CHANGED", payload: { roomConnectionStatus } });
|
|
5804
|
+
});
|
|
5678
5805
|
roomConnection.addEventListener("room_joined", (e) => {
|
|
5679
|
-
const { localParticipant, remoteParticipants } = e.detail;
|
|
5680
|
-
dispatch({ type: "ROOM_JOINED", payload: { localParticipant, remoteParticipants } });
|
|
5806
|
+
const { localParticipant, remoteParticipants, waitingParticipants } = e.detail;
|
|
5807
|
+
dispatch({ type: "ROOM_JOINED", payload: { localParticipant, remoteParticipants, waitingParticipants } });
|
|
5681
5808
|
});
|
|
5682
5809
|
roomConnection.addEventListener("participant_video_enabled", (e) => {
|
|
5683
5810
|
const { participantId, isVideoEnabled } = e.detail;
|
|
@@ -5687,6 +5814,14 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5687
5814
|
const { participantId, displayName } = e.detail;
|
|
5688
5815
|
dispatch({ type: "PARTICIPANT_METADATA_CHANGED", payload: { participantId, displayName } });
|
|
5689
5816
|
});
|
|
5817
|
+
roomConnection.addEventListener("waiting_participant_joined", (e) => {
|
|
5818
|
+
const { participantId, displayName } = e.detail;
|
|
5819
|
+
dispatch({ type: "WAITING_PARTICIPANT_JOINED", payload: { participantId, displayName } });
|
|
5820
|
+
});
|
|
5821
|
+
roomConnection.addEventListener("waiting_participant_left", (e) => {
|
|
5822
|
+
const { participantId } = e.detail;
|
|
5823
|
+
dispatch({ type: "WAITING_PARTICIPANT_LEFT", payload: { participantId } });
|
|
5824
|
+
});
|
|
5690
5825
|
roomConnection.join();
|
|
5691
5826
|
return () => {
|
|
5692
5827
|
roomConnection.leave();
|
|
@@ -5695,16 +5830,28 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5695
5830
|
return {
|
|
5696
5831
|
state,
|
|
5697
5832
|
actions: {
|
|
5698
|
-
|
|
5699
|
-
roomConnection
|
|
5833
|
+
knock: () => {
|
|
5834
|
+
roomConnection.knock();
|
|
5700
5835
|
},
|
|
5701
|
-
|
|
5702
|
-
roomConnection
|
|
5836
|
+
sendChatMessage: (text) => {
|
|
5837
|
+
roomConnection.sendChatMessage(text);
|
|
5703
5838
|
},
|
|
5704
5839
|
setDisplayName: (displayName) => {
|
|
5705
|
-
roomConnection
|
|
5840
|
+
roomConnection.setDisplayName(displayName);
|
|
5706
5841
|
dispatch({ type: "LOCAL_CLIENT_DISPLAY_NAME_CHANGED", payload: { displayName } });
|
|
5707
5842
|
},
|
|
5843
|
+
toggleCamera: (enabled) => {
|
|
5844
|
+
roomConnection.localMedia.toggleCameraEnabled(enabled);
|
|
5845
|
+
},
|
|
5846
|
+
toggleMicrophone: (enabled) => {
|
|
5847
|
+
roomConnection.localMedia.toggleMichrophoneEnabled(enabled);
|
|
5848
|
+
},
|
|
5849
|
+
acceptWaitingParticipant: (participantId) => {
|
|
5850
|
+
roomConnection.acceptWaitingParticipant(participantId);
|
|
5851
|
+
},
|
|
5852
|
+
rejectWaitingParticipant: (participantId) => {
|
|
5853
|
+
roomConnection.rejectWaitingParticipant(participantId);
|
|
5854
|
+
},
|
|
5708
5855
|
},
|
|
5709
5856
|
components: {
|
|
5710
5857
|
VideoView,
|
|
@@ -5713,7 +5860,7 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5713
5860
|
};
|
|
5714
5861
|
}
|
|
5715
5862
|
|
|
5716
|
-
const sdkVersion = "2.0.0-
|
|
5863
|
+
const sdkVersion = "2.0.0-alpha9";
|
|
5717
5864
|
|
|
5718
5865
|
exports.VideoView = VideoView;
|
|
5719
5866
|
exports.sdkVersion = sdkVersion;
|