@defcomm/meetingsdk 0.6.1 → 0.6.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/dist/index.mjs CHANGED
@@ -2606,10 +2606,12 @@ var VideoSDKCore = class {
2606
2606
  stream: null
2607
2607
  }
2608
2608
  });
2609
- this.events.onUserJoined?.({
2609
+ const joinedParticipant = this.state.getParticipant(pid) ?? {
2610
2610
  id: pid,
2611
2611
  name: pname
2612
- });
2612
+ };
2613
+ this.events.onUserJoined?.(joinedParticipant);
2614
+ this.events.onParticipantJoined?.(joinedParticipant);
2613
2615
  },
2614
2616
  onParticipantPresence: (participantId, presence) => {
2615
2617
  if (participantId === this.myId) {
@@ -2638,9 +2640,11 @@ var VideoSDKCore = class {
2638
2640
  return;
2639
2641
  }
2640
2642
  console.log("[SFU] Participant permanently left", pid);
2643
+ const leavingParticipant = this.state.getParticipant(pid) ?? { id: pid };
2641
2644
  this.cleanupRemoteParticipant(pid);
2642
2645
  this.state.removeParticipant(pid);
2643
2646
  this.events.onUserLeft?.(pid);
2647
+ this.events.onParticipantLeft?.(leavingParticipant);
2644
2648
  },
2645
2649
  // TRACKS
2646
2650
  onParticipantMediaState: (participantId, audioMuted, videoMuted) => {
@@ -3243,6 +3247,15 @@ var MeetingProvider = ({
3243
3247
  const connectionStateListeners = useRef(
3244
3248
  /* @__PURE__ */ new Set()
3245
3249
  );
3250
+ const participantJoinedListeners = useRef(
3251
+ /* @__PURE__ */ new Set()
3252
+ );
3253
+ const participantLeftListeners = useRef(
3254
+ /* @__PURE__ */ new Set()
3255
+ );
3256
+ const chatMessageListeners = useRef(
3257
+ /* @__PURE__ */ new Set()
3258
+ );
3246
3259
  if (!sdkRef.current) {
3247
3260
  sdkRef.current = new VideoSDKCore(
3248
3261
  {
@@ -3303,6 +3316,7 @@ var MeetingProvider = ({
3303
3316
  data: msg
3304
3317
  };
3305
3318
  pubSubListeners.current.get("SECURE_CHAT")?.forEach((fn) => fn(pubSubMessage));
3319
+ chatMessageListeners.current.forEach((fn) => fn(msg));
3306
3320
  },
3307
3321
  onReaction: (reaction) => {
3308
3322
  reactionListeners.current.forEach((fn) => fn(reaction));
@@ -3330,6 +3344,12 @@ var MeetingProvider = ({
3330
3344
  connectionStateListeners.current.forEach(
3331
3345
  (fn) => fn(state)
3332
3346
  );
3347
+ },
3348
+ onParticipantJoined: (participant) => {
3349
+ participantJoinedListeners.current.forEach((fn) => fn(participant));
3350
+ },
3351
+ onParticipantLeft: (participant) => {
3352
+ participantLeftListeners.current.forEach((fn) => fn(participant));
3333
3353
  }
3334
3354
  }
3335
3355
  );
@@ -3529,6 +3549,18 @@ var MeetingProvider = ({
3529
3549
  return () => {
3530
3550
  activeSpeakerListeners.current.delete(cb);
3531
3551
  };
3552
+ },
3553
+ onParticipantJoined: (cb) => {
3554
+ participantJoinedListeners.current.add(cb);
3555
+ return () => participantJoinedListeners.current.delete(cb);
3556
+ },
3557
+ onChatMessage: (cb) => {
3558
+ chatMessageListeners.current.add(cb);
3559
+ return () => chatMessageListeners.current.delete(cb);
3560
+ },
3561
+ onParticipantLeft: (cb) => {
3562
+ participantLeftListeners.current.add(cb);
3563
+ return () => participantLeftListeners.current.delete(cb);
3532
3564
  }
3533
3565
  };
3534
3566
  }, [
@@ -3653,6 +3685,18 @@ var useMeeting = (handlers) => {
3653
3685
  if (!handlers?.onNetworkQuality) return;
3654
3686
  return ctx.onNetworkQuality(handlers.onNetworkQuality);
3655
3687
  }, [handlers?.onNetworkQuality]);
3688
+ useEffect3(() => {
3689
+ if (!handlers?.onParticipantJoined) return;
3690
+ return ctx.onParticipantJoined(handlers.onParticipantJoined);
3691
+ }, [handlers?.onParticipantJoined]);
3692
+ useEffect3(() => {
3693
+ if (!handlers?.onParticipantLeft) return;
3694
+ return ctx.onParticipantLeft(handlers.onParticipantLeft);
3695
+ }, [handlers?.onParticipantLeft]);
3696
+ useEffect3(() => {
3697
+ if (!handlers?.onChatMessage) return;
3698
+ return ctx.onChatMessage(handlers.onChatMessage);
3699
+ }, [handlers?.onChatMessage]);
3656
3700
  useEffect3(() => {
3657
3701
  if (!handlers?.onReaction) return;
3658
3702
  return ctx.onReaction(handlers.onReaction);