@eleven-am/pondsocket 0.1.146 → 0.1.148

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.
@@ -56,6 +56,12 @@ class ChannelEngine {
56
56
  get size() {
57
57
  return __classPrivateFieldGet(this, _ChannelEngine_users, "f").size;
58
58
  }
59
+ /**
60
+ * @desc Gets the parent engine
61
+ */
62
+ get parent() {
63
+ return __classPrivateFieldGet(this, _ChannelEngine_parentEngine, "f");
64
+ }
59
65
  /**
60
66
  * @desc Adds a user to the channel
61
67
  * @param userId - The id of the user to add
@@ -70,7 +76,9 @@ class ChannelEngine {
70
76
  throw new pondError_1.ChannelError(message, code, this.name);
71
77
  }
72
78
  __classPrivateFieldGet(this, _ChannelEngine_users, "f").set(userId, assigns);
73
- return __classPrivateFieldGet(this, _ChannelEngine_instances, "m", _ChannelEngine_subscribe).call(this, userId, onMessage);
79
+ const subscription = __classPrivateFieldGet(this, _ChannelEngine_instances, "m", _ChannelEngine_subscribe).call(this, userId, onMessage);
80
+ this.sendMessage(pondsocket_common_1.SystemSender.CHANNEL, [userId], pondsocket_common_1.ServerActions.SYSTEM, pondsocket_common_1.Events.ACKNOWLEDGE, {});
81
+ return subscription;
74
82
  }
75
83
  /**
76
84
  * @desc Kicks a user from the channel
@@ -13,7 +13,6 @@ const createParentEngine = () => {
13
13
  channelName: 'channel',
14
14
  requestId: 'requestId',
15
15
  subscriptions: new Map(),
16
- pendingSubscriptions: new Set(),
17
16
  socket: {
18
17
  send: jest.fn(),
19
18
  },
@@ -160,7 +159,7 @@ describe('ChannelEngine', () => {
160
159
  test: { test: 2 },
161
160
  test2: { test: 3 },
162
161
  });
163
- expect(onMessage).toHaveBeenCalledTimes(3);
162
+ expect(onMessage).toHaveBeenCalledTimes(5);
164
163
  });
165
164
  it('should update a users presence', () => {
166
165
  var _a;
@@ -260,6 +259,7 @@ describe('ChannelEngine', () => {
260
259
  const channelEngine = new channel_1.ChannelEngine('test', parentEngine);
261
260
  channelEngine.addUser('test1', { test: 1 }, onMessage);
262
261
  const unsub = channelEngine.addUser('test2', { test: 1 }, onMessage);
262
+ onMessage.mockClear();
263
263
  socket.subscriptions.set('test', unsub);
264
264
  channelEngine.kickUser('test1', 'test reason');
265
265
  expect(channelEngine.size).toEqual(1);
@@ -299,6 +299,7 @@ describe('ChannelEngine', () => {
299
299
  const channelEngine = new channel_1.ChannelEngine('test', parentEngine);
300
300
  channelEngine.addUser('test', { test: 1 }, onMessage);
301
301
  channelEngine.addUser('test2', { test: 1 }, onMessage);
302
+ onMessage.mockClear();
302
303
  channelEngine.sendMessage(pondsocket_common_1.SystemSender.CHANNEL, pondsocket_common_1.ChannelReceiver.ALL_USERS, pondsocket_common_1.ServerActions.BROADCAST, 'test', { test: 2 });
303
304
  expect(onMessage.mock.calls[0][0]).toStrictEqual(expect.objectContaining({
304
305
  action: pondsocket_common_1.ServerActions.BROADCAST,
@@ -327,6 +328,7 @@ describe('ChannelEngine', () => {
327
328
  const channelEngine = new channel_1.ChannelEngine('test', parentEngine);
328
329
  channelEngine.addUser('test', { test: 1 }, onMessage);
329
330
  channelEngine.addUser('test2', { test: 1 }, onMessage);
331
+ onMessage.mockClear();
330
332
  channelEngine.sendMessage('test2', pondsocket_common_1.ChannelReceiver.ALL_EXCEPT_SENDER, pondsocket_common_1.ServerActions.BROADCAST, 'test', { test: 2 });
331
333
  expect(onMessage.mock.calls[0][0]).toStrictEqual(expect.objectContaining({
332
334
  action: pondsocket_common_1.ServerActions.BROADCAST,
@@ -356,6 +358,7 @@ describe('ChannelEngine', () => {
356
358
  channelEngine.addUser('test', { test: 1 }, onMessage);
357
359
  channelEngine.addUser('test2', { test: 1 }, onMessage);
358
360
  channelEngine.addUser('test3', { test: 1 }, onMessage);
361
+ onMessage.mockClear();
359
362
  channelEngine.sendMessage('test2', ['test', 'test3'], pondsocket_common_1.ServerActions.BROADCAST, 'test', { test: 2 });
360
363
  expect(onMessage.mock.calls[0][0]).toStrictEqual(expect.objectContaining({
361
364
  action: pondsocket_common_1.ServerActions.BROADCAST,
@@ -399,6 +402,7 @@ describe('ChannelEngine', () => {
399
402
  requestId: (0, pondsocket_common_1.uuid)(),
400
403
  })).toThrow('ChannelEngine: User with id test2 does not exist in channel test');
401
404
  channelEngine.addUser('test2', { test: 1 }, onMessage);
405
+ onMessage.mockClear();
402
406
  channelEngine.broadcastMessage('test2', {
403
407
  action: pondsocket_common_1.ClientActions.BROADCAST,
404
408
  channelName: 'test',
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _EndpointEngine_instances, _EndpointEngine_middleware, _EndpointEngine_channels, _EndpointEngine_sockets, _EndpointEngine_parentEngine, _EndpointEngine_sendMessage, _EndpointEngine_joinChannel, _EndpointEngine_execute, _EndpointEngine_retrieveChannel, _EndpointEngine_handleMessage, _EndpointEngine_readMessage, _EndpointEngine_buildError, _EndpointEngine_leaveChannel, _Endpoint_engine;
13
+ var _EndpointEngine_instances, _EndpointEngine_middleware, _EndpointEngine_channels, _EndpointEngine_sockets, _EndpointEngine_parentEngine, _EndpointEngine_joinChannel, _EndpointEngine_execute, _EndpointEngine_retrieveChannel, _EndpointEngine_handleMessage, _EndpointEngine_readMessage, _EndpointEngine_buildError, _EndpointEngine_leaveChannel, _Endpoint_engine;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Endpoint = exports.EndpointEngine = void 0;
16
16
  const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
@@ -30,7 +30,7 @@ class EndpointEngine {
30
30
  _EndpointEngine_parentEngine.set(this, void 0);
31
31
  __classPrivateFieldSet(this, _EndpointEngine_sockets, new Map(), "f");
32
32
  __classPrivateFieldSet(this, _EndpointEngine_middleware, new middleware_1.Middleware(), "f");
33
- __classPrivateFieldSet(this, _EndpointEngine_channels, new Set(), "f");
33
+ __classPrivateFieldSet(this, _EndpointEngine_channels, new Map(), "f");
34
34
  __classPrivateFieldSet(this, _EndpointEngine_parentEngine, parent, "f");
35
35
  }
36
36
  get parent() {
@@ -64,7 +64,7 @@ class EndpointEngine {
64
64
  }
65
65
  next();
66
66
  });
67
- __classPrivateFieldGet(this, _EndpointEngine_channels, "f").add(pondChannel);
67
+ __classPrivateFieldGet(this, _EndpointEngine_channels, "f").set(path, pondChannel);
68
68
  return new lobby_1.PondChannel(pondChannel);
69
69
  }
70
70
  /**
@@ -87,7 +87,7 @@ class EndpointEngine {
87
87
  action: pondsocket_common_1.ServerActions.BROADCAST,
88
88
  channelName: pondsocket_common_1.SystemSender.ENDPOINT,
89
89
  };
90
- __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_sendMessage).call(this, socket, message);
90
+ this.sendMessage(socket, message);
91
91
  });
92
92
  }
93
93
  /**
@@ -142,14 +142,9 @@ class EndpointEngine {
142
142
  subscribeTo(userId, channel) {
143
143
  const user = this.getUser(userId);
144
144
  const channelEngine = __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_retrieveChannel).call(this, channel);
145
- if (!channelEngine) {
146
- user.pendingSubscriptions.add(channel);
147
- }
148
- else {
149
- user.subscriptions.set(channel, channelEngine.addUser(userId, user.assigns, (event) => {
150
- user.socket.send(JSON.stringify(event));
151
- }));
152
- }
145
+ const onMessage = this.sendMessage.bind(this, user.socket);
146
+ const subscription = channelEngine.addUser(userId, user.assigns, onMessage);
147
+ user.subscriptions.set(channel, subscription);
153
148
  }
154
149
  /**
155
150
  * @desc Unsubscribes a user from a channel
@@ -162,55 +157,45 @@ class EndpointEngine {
162
157
  if (unsubscribe) {
163
158
  unsubscribe();
164
159
  user.subscriptions.delete(channel);
160
+ return;
165
161
  }
166
- else if (user.pendingSubscriptions.has(channel)) {
167
- user.pendingSubscriptions.delete(channel);
168
- }
169
- else {
170
- throw new pondError_1.EndpointError(`GatewayEngine: User ${userId} is not subscribed to ${channel}`, 404);
171
- }
162
+ throw new pondError_1.EndpointError(`GatewayEngine: Channel ${channel} does not exist`, 404);
172
163
  }
173
164
  /**
174
- * @desc Subscribes all pending users to a channel
175
- * @param channel - The channel to subscribe the users to
165
+ * @desc Sends a message to a client
166
+ * @param socket - The socket to send the message to
167
+ * @param message - The message to send
176
168
  */
177
- subscribePendingUsers(channel) {
178
- const users = [...__classPrivateFieldGet(this, _EndpointEngine_sockets, "f").values()]
179
- .filter(({ pendingSubscriptions }) => pendingSubscriptions.has(channel.name));
180
- users.forEach(({ clientId, pendingSubscriptions, subscriptions, socket, assigns }) => {
181
- const unsubscribe = channel.addUser(clientId, assigns, (event) => {
182
- socket.send(JSON.stringify(event));
183
- });
184
- subscriptions.set(channel.name, unsubscribe);
185
- pendingSubscriptions.delete(channel.name);
186
- });
169
+ sendMessage(socket, message) {
170
+ socket.send(JSON.stringify(message));
187
171
  }
188
172
  }
189
173
  exports.EndpointEngine = EndpointEngine;
190
- _EndpointEngine_middleware = new WeakMap(), _EndpointEngine_channels = new WeakMap(), _EndpointEngine_sockets = new WeakMap(), _EndpointEngine_parentEngine = new WeakMap(), _EndpointEngine_instances = new WeakSet(), _EndpointEngine_sendMessage = function _EndpointEngine_sendMessage(socket, message) {
191
- socket.send(JSON.stringify(message));
192
- }, _EndpointEngine_joinChannel = function _EndpointEngine_joinChannel(channel, socket, joinParams, requestId) {
174
+ _EndpointEngine_middleware = new WeakMap(), _EndpointEngine_channels = new WeakMap(), _EndpointEngine_sockets = new WeakMap(), _EndpointEngine_parentEngine = new WeakMap(), _EndpointEngine_instances = new WeakSet(), _EndpointEngine_joinChannel = function _EndpointEngine_joinChannel(channel, socket, joinParams, requestId) {
193
175
  const cache = Object.assign(Object.assign({}, socket), { requestId, channelName: channel });
194
176
  __classPrivateFieldGet(this, _EndpointEngine_middleware, "f").run(cache, joinParams, () => {
195
177
  throw new pondError_1.EndpointError(`GatewayEngine: Channel ${channel} does not exist`, 404);
196
178
  });
197
179
  }, _EndpointEngine_execute = function _EndpointEngine_execute(channel, handler) {
198
- for (const manager of __classPrivateFieldGet(this, _EndpointEngine_channels, "f")) {
199
- const isPresent = manager.listChannels()
200
- .includes(channel);
201
- if (isPresent) {
180
+ for (const [path, manager] of __classPrivateFieldGet(this, _EndpointEngine_channels, "f")) {
181
+ const event = (0, matcher_1.parseAddress)(path, channel);
182
+ if (event) {
202
183
  return manager.execute(channel, handler);
203
184
  }
204
185
  }
205
- throw new Error(`GatewayEngine: Channel ${channel} does not exist`);
206
186
  }, _EndpointEngine_retrieveChannel = function _EndpointEngine_retrieveChannel(channel) {
207
- for (const manager of __classPrivateFieldGet(this, _EndpointEngine_channels, "f")) {
208
- const isPresent = manager.listChannels()
209
- .includes(channel);
210
- if (isPresent) {
211
- return manager.getChannel(channel);
187
+ let channelEngine;
188
+ for (const [path, manager] of __classPrivateFieldGet(this, _EndpointEngine_channels, "f")) {
189
+ const event = (0, matcher_1.parseAddress)(path, channel);
190
+ if (event) {
191
+ channelEngine = manager.getChannel(channel) || manager.createChannel(channel);
192
+ break;
212
193
  }
213
194
  }
195
+ if (!channelEngine) {
196
+ throw new Error(`GatewayEngine: Channel ${channel} does not exist`);
197
+ }
198
+ return channelEngine;
214
199
  }, _EndpointEngine_handleMessage = function _EndpointEngine_handleMessage(cache, message) {
215
200
  switch (message.action) {
216
201
  case pondsocket_common_1.ClientActions.JOIN_CHANNEL:
@@ -234,7 +219,7 @@ _EndpointEngine_middleware = new WeakMap(), _EndpointEngine_channels = new WeakM
234
219
  __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_handleMessage).call(this, cache, result);
235
220
  }
236
221
  catch (e) {
237
- __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_sendMessage).call(this, cache.socket, __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_buildError).call(this, e));
222
+ this.sendMessage(cache.socket, __classPrivateFieldGet(this, _EndpointEngine_instances, "m", _EndpointEngine_buildError).call(this, e));
238
223
  }
239
224
  }, _EndpointEngine_buildError = function _EndpointEngine_buildError(error) {
240
225
  const event = {
@@ -27,6 +27,7 @@ const createEndpointEngine = (socket) => ({
27
27
  getUser: () => socket,
28
28
  subscribeTo: jest.fn(),
29
29
  unsubscribeFrom: jest.fn(),
30
+ sendMessage: (socket, msg) => socket.send(JSON.stringify(msg)),
30
31
  });
31
32
  exports.createEndpointEngine = createEndpointEngine;
32
33
  describe('endpoint', () => {
@@ -61,7 +61,6 @@ class ConnectionResponse {
61
61
  socket: __classPrivateFieldGet(this, _ConnectionResponse_webSocket, "f"),
62
62
  assigns: __classPrivateFieldGet(this, _ConnectionResponse_assigns, "f"),
63
63
  subscriptions: new Map(),
64
- pendingSubscriptions: new Set(),
65
64
  };
66
65
  __classPrivateFieldGet(this, _ConnectionResponse_engine, "f").manageSocket(cache);
67
66
  return this;
@@ -116,7 +115,7 @@ _ConnectionResponse_webSocket = new WeakMap(), _ConnectionResponse_engine = new
116
115
  requestId: __classPrivateFieldGet(this, _ConnectionResponse_requestId, "f"),
117
116
  channelName: pondsocket_common_1.SystemSender.ENDPOINT,
118
117
  };
119
- __classPrivateFieldGet(this, _ConnectionResponse_webSocket, "f").send(JSON.stringify(message));
118
+ __classPrivateFieldGet(this, _ConnectionResponse_engine, "f").sendMessage(__classPrivateFieldGet(this, _ConnectionResponse_webSocket, "f"), message);
120
119
  }, _ConnectionResponse_performChecks = function _ConnectionResponse_performChecks() {
121
120
  if (__classPrivateFieldGet(this, _ConnectionResponse_executed, "f")) {
122
121
  const message = 'Cannot execute response more than once';
@@ -11,7 +11,6 @@ const createMockSocket = () => {
11
11
  channelName: 'channel',
12
12
  requestId: 'requestId',
13
13
  subscriptions: new Map(),
14
- pendingSubscriptions: new Set(),
15
14
  socket: {
16
15
  send: jest.fn(),
17
16
  },
@@ -52,6 +52,8 @@ describe('JoinResponse', () => {
52
52
  const { response, channelEngine, socket } = createPondResponse();
53
53
  // spy on the channelEngine to see if the user was added
54
54
  jest.spyOn(channelEngine, 'addUser');
55
+ const endpoint = channelEngine.parent.parent;
56
+ jest.spyOn(endpoint, 'sendMessage');
55
57
  response
56
58
  .accept()
57
59
  .reply('POND_MESSAGE', { message: 'message' })
@@ -68,11 +70,17 @@ describe('JoinResponse', () => {
68
70
  // also check if the socket was sent a message
69
71
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
70
72
  // @ts-expect-error - we are mocking the socket
71
- const first = socket.socket.send.mock.calls[0][0];
73
+ const first = endpoint.sendMessage.mock.calls[0][1];
72
74
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
73
75
  // @ts-expect-error - we are mocking the socket
74
- const params = socket.socket.send.mock.calls[1][0];
75
- expect(JSON.parse(params)).toEqual(expect.objectContaining({
76
+ const params = endpoint.sendMessage.mock.calls[1][1];
77
+ expect(first).toEqual(expect.objectContaining({
78
+ channelName: 'test',
79
+ action: pondsocket_common_1.ServerActions.SYSTEM,
80
+ payload: {},
81
+ event: pondsocket_common_1.Events.ACKNOWLEDGE,
82
+ }));
83
+ expect(params).toEqual(expect.objectContaining({
76
84
  channelName: 'test',
77
85
  action: pondsocket_common_1.ServerActions.SYSTEM,
78
86
  payload: {
@@ -80,12 +88,6 @@ describe('JoinResponse', () => {
80
88
  },
81
89
  event: 'POND_MESSAGE',
82
90
  }));
83
- expect(JSON.parse(first)).toEqual(expect.objectContaining({
84
- channelName: 'test',
85
- action: pondsocket_common_1.ServerActions.SYSTEM,
86
- payload: {},
87
- event: pondsocket_common_1.Events.ACKNOWLEDGE,
88
- }));
89
91
  });
90
92
  // auxiliary functions
91
93
  it('should send messages to different users', () => {
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _JoinResponse_instances, _JoinResponse_user, _JoinResponse_engine, _JoinResponse_newAssigns, _JoinResponse_executed, _JoinResponse_accepted, _JoinResponse_performChecks, _JoinResponse_sendMessage;
13
+ var _JoinResponse_instances, _JoinResponse_user, _JoinResponse_engine, _JoinResponse_newAssigns, _JoinResponse_executed, _JoinResponse_accepted, _JoinResponse_performChecks, _JoinResponse_sendMessage, _JoinResponse_directMessage;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.JoinResponse = void 0;
16
16
  const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
@@ -53,17 +53,8 @@ class JoinResponse {
53
53
  */
54
54
  accept() {
55
55
  __classPrivateFieldGet(this, _JoinResponse_instances, "m", _JoinResponse_performChecks).call(this);
56
- const acknowledgement = {
57
- action: pondsocket_common_1.ServerActions.SYSTEM,
58
- channelName: __classPrivateFieldGet(this, _JoinResponse_engine, "f").name,
59
- event: pondsocket_common_1.Events.ACKNOWLEDGE,
60
- requestId: __classPrivateFieldGet(this, _JoinResponse_user, "f").requestId,
61
- payload: {},
62
- };
63
- __classPrivateFieldGet(this, _JoinResponse_user, "f").socket.send(JSON.stringify(acknowledgement));
64
- const unsubscribe = __classPrivateFieldGet(this, _JoinResponse_engine, "f").addUser(__classPrivateFieldGet(this, _JoinResponse_user, "f").clientId, __classPrivateFieldGet(this, _JoinResponse_newAssigns, "f"), (event) => {
65
- __classPrivateFieldGet(this, _JoinResponse_user, "f").socket.send(JSON.stringify(event));
66
- });
56
+ const onMessage = __classPrivateFieldGet(this, _JoinResponse_instances, "m", _JoinResponse_directMessage).bind(this);
57
+ const unsubscribe = __classPrivateFieldGet(this, _JoinResponse_engine, "f").addUser(__classPrivateFieldGet(this, _JoinResponse_user, "f").clientId, __classPrivateFieldGet(this, _JoinResponse_newAssigns, "f"), onMessage);
67
58
  __classPrivateFieldGet(this, _JoinResponse_user, "f").subscriptions.set(__classPrivateFieldGet(this, _JoinResponse_engine, "f").name, unsubscribe);
68
59
  __classPrivateFieldSet(this, _JoinResponse_accepted, true, "f");
69
60
  return this;
@@ -85,7 +76,7 @@ class JoinResponse {
85
76
  action: pondsocket_common_1.ServerActions.ERROR,
86
77
  requestId: __classPrivateFieldGet(this, _JoinResponse_user, "f").requestId,
87
78
  };
88
- __classPrivateFieldGet(this, _JoinResponse_user, "f").socket.send(JSON.stringify(errorMessage));
79
+ __classPrivateFieldGet(this, _JoinResponse_instances, "m", _JoinResponse_directMessage).call(this, errorMessage);
89
80
  return this;
90
81
  }
91
82
  /**
@@ -101,7 +92,7 @@ class JoinResponse {
101
92
  payload,
102
93
  event,
103
94
  };
104
- __classPrivateFieldGet(this, _JoinResponse_user, "f").socket.send(JSON.stringify(message));
95
+ __classPrivateFieldGet(this, _JoinResponse_instances, "m", _JoinResponse_directMessage).call(this, message);
105
96
  return this;
106
97
  }
107
98
  /**
@@ -168,4 +159,6 @@ _JoinResponse_user = new WeakMap(), _JoinResponse_engine = new WeakMap(), _JoinR
168
159
  __classPrivateFieldSet(this, _JoinResponse_executed, true, "f");
169
160
  }, _JoinResponse_sendMessage = function _JoinResponse_sendMessage(recipient, event, payload) {
170
161
  __classPrivateFieldGet(this, _JoinResponse_engine, "f").sendMessage(__classPrivateFieldGet(this, _JoinResponse_user, "f").clientId, recipient, pondsocket_common_1.ServerActions.BROADCAST, event, payload, __classPrivateFieldGet(this, _JoinResponse_user, "f").requestId);
162
+ }, _JoinResponse_directMessage = function _JoinResponse_directMessage(event) {
163
+ __classPrivateFieldGet(this, _JoinResponse_engine, "f").parent.parent.sendMessage(__classPrivateFieldGet(this, _JoinResponse_user, "f").socket, event);
171
164
  };
package/lobby/lobby.js CHANGED
@@ -26,12 +26,21 @@ class LobbyEngine {
26
26
  __classPrivateFieldSet(this, _LobbyEngine_channels, new Set(), "f");
27
27
  __classPrivateFieldSet(this, _LobbyEngine_middleware, new middleware_1.Middleware(), "f");
28
28
  }
29
+ /**
30
+ * @desc The parent engine
31
+ */
29
32
  get parent() {
30
33
  return __classPrivateFieldGet(this, _LobbyEngine_parentEngine, "f");
31
34
  }
35
+ /**
36
+ * @desc The leave callback
37
+ */
32
38
  get leaveCallback() {
33
39
  return __classPrivateFieldGet(this, _LobbyEngine_leaveCallback, "f");
34
40
  }
41
+ /**
42
+ * @desc The middleware to use
43
+ */
35
44
  get middleware() {
36
45
  return __classPrivateFieldGet(this, _LobbyEngine_middleware, "f");
37
46
  }
@@ -120,14 +129,6 @@ class LobbyEngine {
120
129
  __classPrivateFieldGet(this, _LobbyEngine_channels, "f").delete(newChannel);
121
130
  }
122
131
  }
123
- /**
124
- * @desc Lists all channels
125
- * @private
126
- */
127
- listChannels() {
128
- return Array.from(__classPrivateFieldGet(this, _LobbyEngine_channels, "f"))
129
- .map((channel) => channel.name);
130
- }
131
132
  /**
132
133
  * @desc Creates a new channel
133
134
  * @param channelName - The name of the channel to create
@@ -135,7 +136,6 @@ class LobbyEngine {
135
136
  */
136
137
  createChannel(channelName) {
137
138
  const newChannel = new channel_1.ChannelEngine(channelName, this);
138
- __classPrivateFieldGet(this, _LobbyEngine_parentEngine, "f").subscribePendingUsers(newChannel);
139
139
  __classPrivateFieldGet(this, _LobbyEngine_channels, "f").add(newChannel);
140
140
  return newChannel;
141
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.146",
3
+ "version": "0.1.148",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -39,10 +39,10 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jest": "^29.5.12",
42
- "@types/node": "^20.11.20",
42
+ "@types/node": "^20.11.24",
43
43
  "@types/websocket": "^1.0.10",
44
44
  "@types/ws": "^8.5.10",
45
- "@typescript-eslint/eslint-plugin": "^7.0.2",
45
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
46
46
  "eslint": "^8.57.0",
47
47
  "eslint-plugin-file-progress": "^1.3.0",
48
48
  "eslint-plugin-import": "^2.29.1",
@@ -84,6 +84,7 @@ describe('PresenceEngine', () => {
84
84
  channel.addUser('presenceKey2', { assign: 'assign' }, () => {
85
85
  // do nothing
86
86
  });
87
+ listener.mockClear();
87
88
  presenceEngine.trackPresence(presenceKey, presence);
88
89
  presenceEngine.trackPresence('presenceKey2', Object.assign(Object.assign({}, presence), { key: 'presence2' }));
89
90
  expect(listener).toHaveBeenCalledTimes(2);