Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

feat: realtime component presence #739

Merged
merged 9 commits into from
Aug 12, 2024

Conversation

Raspincel
Copy link
Contributor

Create a "presence" property to all channels. We internally understand it as "presence", but it is being called "participant"

There are 4 methods:

  public update(data: any);
  public subscribe<T>(event: PresenceEvents, callback: PresenceCallback<T>);
  public unsubscribe(event: PresenceEvents);
  public getAll(): PresenceEvent;

The types are:

type PresenceEvent<T = unknown> = {
  id: string;
  name: string;
  connectionId: string;
  data: T;
  timestamp: number;
};

type PresenceCallback<T = unknown> = (event: PresenceEvent<T>) => void;

enum PresenceEvents {
  JOINED_ROOM = 'presence.joined-room',
  LEAVE = 'presence.leave',
  ERROR = 'presence.error',
  UPDATE = 'presence.update',
}

Example of usage:

const channel = await realtime.connect('channel-name');

const callback = ({ data }) => {
  console.log("update presence", data);
}

channel.participant.subscribe(PresenceEvents.UPDATE, callback);
channel.participant.update({ name: "John" });
channel.participant.unsubscribe(PresenceEvents.UPDATE);
const presences = channel.participant.getAll();

Fix: when trying to connect to a channel immediately after initializing the SDK and adding the realtime component, it threw an error because the IOC wasn't even defined (the start method of the realtime component wasn't even called at this point, so a lot was undefined). Now, in these cases, connect returns a promise that only later, when the Realtime component is added, it resolves as a Channel

src/components/realtime/presence.ts Outdated Show resolved Hide resolved
src/components/realtime/presence.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot deleted a comment from SuperViz-Dev Aug 12, 2024
@github-actions github-actions bot deleted a comment from SuperViz-Dev Aug 12, 2024
@github-actions github-actions bot deleted a comment from SuperViz-Dev Aug 12, 2024
@github-actions github-actions bot deleted a comment from SuperViz-Dev Aug 12, 2024
@SuperViz-Dev
Copy link
Contributor

Total Coverage: 88.16%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   shims.d.ts 100% 100% 100%
src/common
src/common/types
   colors.types.ts 100% 100% 100%
   events.types.ts 100% 100% 100%
   meeting-colors.types.ts 100% 100% 100%
   participant.types.ts 100% 100% 100%
   realtime.types.ts 100% 100% 100%
   sdk-options.types.ts 100% 100% 100%
   stores.types.ts 100% 100% 100%
src/common/utils
   do-request.ts 100% 100% 87.50% 20
   index.ts 100% 100% 100%
   logger.ts 100% 100% 100%
   observable.ts 100% 100% 100%
   observer.ts 100% 100% 100%
   sleep.ts 0% 100% 100% 2
   use-store.ts 80% 100% 100% 34
src/components
   index.ts 100% 75% 100%
   types.ts 100% 100% 100%
src/components/base
   index.ts 75% 100% 94% 44, 45, 46, 47, 55
src/components/comments
   index.ts 94.44% 93.33% 96.40% 241, 298, 357, 358, 359, 361, 479, 517, 586, 699, 715
   types.ts 100% 100% 100%
src/components/comments/canvas-pin-adapter
   index.ts 54.55% 85.71% 88.19% 204, 251, 251, 251, 251, 252, 253, 256, 256, 257, 260, 330, 331, 333, 333, 333, 335, 335, 336, 338, 339, 342, 344, 393, 394, 395, 414, 425, 436, 440, 453, 474, 499, 519, 520, 531, 532, 533, 534, 535, 535, 535, 535, 535, 537, 537, 538, 538, 538, 538, 542, 544, 545
src/components/comments/html-pin-adapter
   index.ts 91.59% 96.55% 96.35% 277, 278, 279, 336, 363, 470, 471, 492, 493, 495, 495, 497, 498, 500, 500, 500, 500, 502, 503, 718, 719, 720, 797, 798, 799
src/components/form-elements
   index.ts 98.48% 100% 100% 96
   types.ts 100% 100% 100%
src/components/presence-mouse
   index.ts 50% 50% 90% 10, 11
   types.ts 100% 100% 100%
src/components/presence-mouse/canvas
   index.ts 63.16% 77.27% 87.64% 102, 103, 112, 113, 114, 115, 135, 135, 137, 161, 164, 164, 165, 166, 244, 244, 244, 244, 328, 338, 339, 356, 356, 358, 417, 79, 80, 81, 82, 83, 85, 86, 87, 88, 97, 98
src/components/presence-mouse/html
   index.ts 89.47% 96.97% 99.39% 282, 282, 284, 304, 566, 681, 699, 700
src/components/realtime
   channel.ts 71.43% 80% 88.31% 133, 133, 135, 137, 138, 141, 143, 147, 148, 150, 150, 95, 96
   index.ts 25% 62.50% 69.84% 111, 124, 132, 132, 134, 135, 138, 139, 141, 142, 49, 50, 51, 53, 54, 54, 56, 57, 63, 74, 74, 75, 91, 92, 93
   presence.ts 100% 71.43% 77.78% 32, 35, 36, 37
   types.ts 100% 100% 100%
src/components/video
   index.ts 76.54% 95.16% 89.90% 107, 108, 109, 121, 122, 123, 144, 145, 146, 233, 358, 582, 591, 626, 725, 726, 728, 728, 729, 730, 733, 780, 783, 783, 791, 792, 795, 796, 832, 853, 854, 856, 856, 857, 863, 878, 910, 911, 915, 916, 93, 936, 94, 941, 941, 942, 945, 95, 953
src/components/who-is-online
   index.ts 92.77% 98.04% 97.14% 178, 179, 199, 255, 353, 586, 586, 750, 751, 753, 799, 799, 801, 802
   types.ts 100% 100% 100%
src/core
   index.ts 82.76% 62.50% 80.65% 102, 102, 104, 105, 106, 126, 127, 148, 151, 155, 156, 158, 163, 163, 172, 174, 180
src/core/launcher
   index.ts 70% 63.64% 84.09% 102, 103, 104, 104, 105, 107, 133, 135, 136, 140, 143, 294, 296, 297, 305, 310, 328, 328, 329, 330, 333, 333, 334, 335, 348, 348, 350, 352, 354, 355, 357, 358, 359, 423
src/lib
src/lib/socket
   index.ts 100% 0% 0% 1, 10, 11, 12, 13, 2, 21, 22, 3, 5, 6
src/lib/socket/common
src/lib/socket/common/types
   event.types.ts 0% 0% 0% 10, 10, 10, 11, 12, 13, 14, 15, 18, 18, 18, 19, 30, 30, 30, 31, 32, 33, 34, 44, 44, 44, 45
   presence.types.ts 100% 100% 0% 1, 3
src/lib/socket/connection
   index.ts 0% 0% 0% 1, 100, 101, 102, 105, 106, 107, 110, 111, 112, 115, 116, 116, 117, 118, 121, 126, 126, 127, 128, 131, 15, 16, 17, 18, 22, 22, 23, 26, 33, 33, 35, 44, 45, 46, 47, 48, 49, 50, 51, 54, 6, 63, 65, 65, 67, 7, 75, 76, 77, 80, 81, 82, 85, 86, 87, 9, 90, 91, 92, 95, 96, 97
   types.ts 0% 0% 0% 11, 11, 11, 12, 13, 14, 15, 16, 17, 43, 43, 43, 44
src/lib/socket/presence
   index.ts 0% 0% 0% 1, 102, 103, 104, 119, 13, 133, 134, 135, 144, 145, 146, 15, 155, 156, 156, 158, 159, 160, 17, 175, 176, 176, 178, 179, 18, 180, 189, 190, 190, 192, 193, 20, 21, 23, 24, 28, 37, 39, 44, 5, 50, 58, 59, 60, 61, 64, 65, 75, 83, 84, 88, 89, 90, 92, 93
src/lib/socket/realtime
   index.ts 100% 0% 0% 1, 14, 15, 16, 18, 32, 33, 4, 41, 45, 55, 59, 6, 60, 8
src/lib/socket/room
   index.ts 0% 0% 0% 1, 10, 101, 101, 102, 103, 106, 115, 116, 12, 125, 127, 132, 133, 134, 135, 136, 137, 14, 140, 141, 15, 150, 151, 154, 155, 156, 157, 159, 16, 170, 172, 172, 172, 172, 174, 183, 184, 185, 188, 197, 198, 198, 200, 201, 202, 205, 206, 21, 22, 23, 24, 25, 25, 27, 29, 35, 36, 37, 47, 5, 58, 60, 62, 62, 63, 64, 66, 67, 7, 71, 82, 84, 84, 85, 86, 87, 90
   types.ts 100% 100% 0% 1, 30
src/services
src/services/api
   index.ts 100% 88.24% 88.33% 102, 103, 105, 111, 112, 113, 114
src/services/auth-service
   index.ts 100% 100% 100%
src/services/browser
   index.ts 100% 100% 100%
src/services/config
   index.ts 100% 100% 100%
src/services/connection-status
   index.ts 100% 100% 100%
src/services/event-bus
   index.ts 100% 100% 100%
src/services/frame-brick-layer
   index.ts 100% 100% 100%
src/services/io
   index.ts 40% 83.33% 62.07% 39, 39, 40, 44, 49, 51, 54, 54, 55, 56, 57, 60, 61, 71
   types.ts 100% 100% 100%
src/services/limits
   index.ts 75% 100% 100% 11
src/services/message-bridge
   index.ts 93.33% 100% 100% 83
src/services/presence-3d-manager
   index.ts 89.47% 92.59% 97.92% 159, 33, 55, 62
   types.ts 100% 100% 100%
src/services/remote-config-service
   index.ts 100% 80% 92.31% 35
src/services/room-state
   index.ts 82.05% 96.55% 97.86% 135, 162, 248, 258, 380, 380, 382, 383, 60, 72
   type.ts 100% 100% 100%
src/services/slot
   index.ts 28% 58.33% 65.79% 143, 145, 145, 146, 148, 153, 156, 156, 156, 156, 158, 158, 159, 161, 166, 173, 182, 183, 187, 187, 187, 190, 190, 190, 192, 202, 202, 204, 206, 206, 206, 206, 207, 208, 211, 211, 211, 211, 212, 215, 39, 60, 69, 70
src/services/stores
   index.ts 100% 100% 100%
src/services/stores/common
   utils.ts 100% 100% 100%
src/services/stores/global
   index.ts 0% 100% 96.15% 16, 17
src/services/stores/presence3D
   index.ts 0% 66.67% 81.25% 13, 14, 21, 22
src/services/stores/subject
   index.ts 100% 100% 100%
src/services/stores/video
   index.ts 0% 100% 96.97% 20, 21
src/services/stores/who-is-online
   index.ts 0% 100% 97.87% 25, 26
src/services/video-conference-manager
   index.ts 61.90% 84.21% 93.53% 121, 124, 125, 126, 170, 175, 207, 208, 213, 214, 215, 218, 218, 219, 221, 222, 300, 312, 334, 361, 362, 363, 416, 450, 561, 573, 616, 620, 679
   types.ts 100% 100% 100%

@SuperViz-Dev
Copy link
Contributor

Total Coverage: 97.35%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
src/web-components
src/web-components/base
   index.ts 75% 100% 83.52% 28, 32, 33, 34, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
src/web-components/base/styles
   icon-button.style.ts 100% 100% 100%
   index.ts 100% 100% 100%
   sv-hr.style.ts 100% 100% 100%
   typography.style.ts 100% 100% 100%
   variables.style.ts 100% 100% 100%
src/web-components/base/utils
   importStyle.ts 66.67% 100% 100% 3
src/web-components/comments
   comments.ts 88.24% 76.92% 87.80% 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 137, 64, 65, 66, 79, 80, 94, 95, 96, 97, 98, 99
   index.ts 100% 100% 100%
src/web-components/comments/components
   annotation-filter.ts 100% 100% 100%
   annotation-item.ts 100% 96.43% 96.71% 179, 180, 181, 182, 183, 184, 185, 186, 230, 231
   annotation-pin.ts 100% 100% 95.19% 118, 123, 124, 125, 126, 183, 184, 185, 74, 75, 76, 77, 78
   annotation-resolved.ts 100% 100% 100%
   comment-input.ts 100% 96.67% 97.72% 237, 238, 239, 242, 243, 271, 272, 372, 373, 387, 388
   comment-item.ts 100% 90.48% 96.43% 102, 103, 104, 279, 280, 89, 90, 91, 92, 95, 96
   content.ts 96.15% 81.82% 89.23% 108, 109, 39, 40, 43, 44, 45, 51, 52, 53, 67, 78, 79, 80, 81
   delete-comment-modal.ts 100% 100% 100%
   float-button.ts 100% 100% 87.65% 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 50, 51, 55, 56, 72, 81
   index.ts 100% 100% 100%
   mention-list.ts 100% 100% 100%
   topbar.ts 100% 100% 100%
   types.ts 100% 100% 100%
src/web-components/comments/css
   annotation-filter.style.ts 100% 100% 100%
   annotation-item.style.ts 100% 100% 100%
   annotation-pin.style.ts 100% 100% 100%
   annotation-resolved.style.ts 100% 100% 100%
   comment-input.style.ts 100% 100% 100%
   comment-item.style.ts 100% 100% 100%
   comments.style.ts 100% 100% 100%
   content.style.ts 100% 100% 100%
   float-button.style.ts 100% 100% 100%
   index.ts 100% 100% 100%
   mention-list.style.ts 100% 100% 100%
   powered-by.style.ts 100% 100% 100%
   topbar.style.ts 100% 100% 100%
src/web-components/comments/utils
   autocomplete-handler.ts 100% 100% 98.29% 25, 26
   mention-handler.ts 100% 100% 100%
   watermark.ts 100% 100% 86.15% 15, 16, 17, 18, 19, 20, 21, 22, 23
src/web-components/dropdown
   index.style.ts 100% 100% 100%
   index.ts 92.31% 100% 97.67% 156, 157, 158, 159, 160, 161, 189, 223, 260, 83, 86
src/web-components/hello-world
   index.ts 100% 100% 100%
src/web-components/icon
   index.ts 100% 100% 100%
   types.ts 100% 100% 100%
src/web-components/modal
   index.ts 100% 100% 100%
   modal-container.ts 100% 100% 100%
   modal.ts 100% 100% 100%
src/web-components/modal/styles
   index.style.ts 100% 100% 100%
src/web-components/tooltip
   index.style.ts 100% 100% 100%
   index.ts 85.19% 100% 95.15% 109, 110, 111, 112, 114, 115, 116, 117, 152, 156, 221, 222, 223, 224, 88, 90, 91, 92, 94, 95, 96
   types.ts 100% 100% 100%
src/web-components/who-is-online
   index.ts 100% 100% 100%
   who-is-online.ts 87.88% 100% 96.93% 100, 247, 248, 266, 267, 268, 280, 281, 282, 294, 295, 296, 324, 325, 326, 69, 70, 75, 76
src/web-components/who-is-online/components
   dropdown.ts 97.37% 94.74% 97.84% 135, 136, 137, 138, 139, 140, 143
   index.ts 100% 100% 100%
   messages.ts 96.67% 80% 97.29% 127, 128, 136, 137, 145, 146, 42
   types.ts 100% 100% 100%
src/web-components/who-is-online/css
   dropdown.style.ts 100% 100% 100%
   index.ts 100% 100% 100%
   messages.style.ts 100% 100% 100%
   who-is-online-style.ts 100% 100% 100%

@carlossantos74 carlossantos74 merged commit 07142e3 into lab Aug 12, 2024
4 checks passed
@SuperViz-Dev
Copy link
Contributor

🎉 This PR is included in version 6.6.0-lab.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@SuperViz-Dev
Copy link
Contributor

🎉 This PR is included in version 6.6.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@SuperViz-Dev
Copy link
Contributor

🎉 This PR is included in version 6.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants