@webex/internal-plugin-mercury 3.11.0-next.8 → 3.11.0-next.9

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/README.md CHANGED
@@ -29,6 +29,60 @@ const webex = new WebexCore();
29
29
  webex.internal.mercury.WHATEVER;
30
30
  ```
31
31
 
32
+ ### Multiple Connections
33
+
34
+ Mercury now supports multiple simultaneous websocket connections scoped by `sessionId`.
35
+
36
+ ```js
37
+ const mercury = webex.internal.mercury;
38
+
39
+ // Default session
40
+ await mercury.connect();
41
+
42
+ // Additional session
43
+ await mercury.connect(undefined, 'secondary-session');
44
+
45
+ // Disconnect only one session
46
+ await mercury.disconnect(undefined, 'secondary-session');
47
+
48
+ // Disconnect everything
49
+ await mercury.disconnectAll();
50
+ ```
51
+
52
+ #### Listening to multiple connections
53
+
54
+ ```js
55
+ const mercury = webex.internal.mercury;
56
+ const secondarySessionId = 'secondary-session';
57
+
58
+ // Connect both sessions first.
59
+ await mercury.connect();
60
+ await mercury.connect(undefined, secondarySessionId);
61
+
62
+ // Default session listeners use the base event name.
63
+ mercury.on('online', () => {
64
+ console.log('[default] online');
65
+ });
66
+
67
+ mercury.on('event:conversation.activity', (envelope) => {
68
+ console.log('[default] activity', envelope.data?.eventType);
69
+ });
70
+
71
+ // Non-default sessions use :<sessionId> suffix.
72
+ mercury.on(`online:${secondarySessionId}`, () => {
73
+ console.log(`[${secondarySessionId}] online`);
74
+ });
75
+
76
+ mercury.on(`event:conversation.activity:${secondarySessionId}`, (envelope) => {
77
+ console.log(`[${secondarySessionId}] activity`, envelope.data?.eventType);
78
+ });
79
+ ```
80
+
81
+ Notes:
82
+ - `connect(webSocketUrl, sessionId)` and `disconnect(options, sessionId)` are session-aware.
83
+ - Non-default sessions emit events with a `:<sessionId>` suffix (for example, `online:secondary-session`).
84
+ - `getSocket(sessionId)` returns the socket for a specific session.
85
+
32
86
  ## Config Options
33
87
 
34
88
  ### Using A Proxy Agent To Open A Websocket Connection