@eleven-am/pondsocket 0.1.176 → 0.1.177

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.176",
3
+ "version": "0.1.177",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -10,12 +10,13 @@ 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 _PondChannel_lobby;
13
+ var _PondChannel_instances, _PondChannel_lobby, _PondChannel_getChannel;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.PondChannel = void 0;
16
16
  const channel_1 = require("./channel");
17
17
  class PondChannel {
18
18
  constructor(lobby) {
19
+ _PondChannel_instances.add(this);
19
20
  _PondChannel_lobby.set(this, void 0);
20
21
  __classPrivateFieldSet(this, _PondChannel_lobby, lobby, "f");
21
22
  }
@@ -28,21 +29,28 @@ class PondChannel {
28
29
  return this;
29
30
  }
30
31
  getChannel(channelName) {
31
- const channel = __classPrivateFieldGet(this, _PondChannel_lobby, "f").getChannel(channelName);
32
- return new channel_1.Channel(channel);
32
+ try {
33
+ return __classPrivateFieldGet(this, _PondChannel_instances, "m", _PondChannel_getChannel).call(this, channelName);
34
+ }
35
+ catch (_a) {
36
+ return null;
37
+ }
33
38
  }
34
39
  broadcast(channelName, event, payload) {
35
- this.getChannel(channelName).broadcast(event, payload);
40
+ __classPrivateFieldGet(this, _PondChannel_instances, "m", _PondChannel_getChannel).call(this, channelName).broadcast(event, payload);
36
41
  return this;
37
42
  }
38
43
  broadcastFrom(channelName, userId, event, payload) {
39
- this.getChannel(channelName).broadcastFrom(userId, event, payload);
44
+ __classPrivateFieldGet(this, _PondChannel_instances, "m", _PondChannel_getChannel).call(this, channelName).broadcastFrom(userId, event, payload);
40
45
  return this;
41
46
  }
42
47
  broadcastTo(channelName, userIds, event, payload) {
43
- this.getChannel(channelName).broadcastTo(userIds, event, payload);
48
+ __classPrivateFieldGet(this, _PondChannel_instances, "m", _PondChannel_getChannel).call(this, channelName).broadcastTo(userIds, event, payload);
44
49
  return this;
45
50
  }
46
51
  }
47
52
  exports.PondChannel = PondChannel;
48
- _PondChannel_lobby = new WeakMap();
53
+ _PondChannel_lobby = new WeakMap(), _PondChannel_instances = new WeakSet(), _PondChannel_getChannel = function _PondChannel_getChannel(channelName) {
54
+ const channel = __classPrivateFieldGet(this, _PondChannel_lobby, "f").getChannel(channelName);
55
+ return new channel_1.Channel(channel);
56
+ };