@eleven-am/pondsocket 0.1.88 → 0.1.89

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.
@@ -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 _Endpoint_instances, _Endpoint_middleware, _Endpoint_server, _Endpoint_channels, _Endpoint_sockets, _Endpoint_sendMessage, _Endpoint_joinChannel, _Endpoint_execute, _Endpoint_handleMessage, _Endpoint_readMessage, _Endpoint_isObjectEmpty;
13
+ var _Endpoint_instances, _Endpoint_middleware, _Endpoint_channels, _Endpoint_sockets, _Endpoint_sendMessage, _Endpoint_joinChannel, _Endpoint_execute, _Endpoint_handleMessage, _Endpoint_readMessage, _Endpoint_isObjectEmpty;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Endpoint = void 0;
16
16
  const middleware_1 = require("../abstracts/middleware");
@@ -21,13 +21,11 @@ const joinResponse_1 = require("../lobby/joinResponse");
21
21
  const lobby_1 = require("../lobby/lobby");
22
22
  const matcher_1 = require("../matcher/matcher");
23
23
  class Endpoint {
24
- constructor(server) {
24
+ constructor() {
25
25
  _Endpoint_instances.add(this);
26
26
  _Endpoint_middleware.set(this, void 0);
27
- _Endpoint_server.set(this, void 0);
28
27
  _Endpoint_channels.set(this, void 0);
29
28
  _Endpoint_sockets.set(this, void 0);
30
- __classPrivateFieldSet(this, _Endpoint_server, server, "f");
31
29
  __classPrivateFieldSet(this, _Endpoint_sockets, new Set(), "f");
32
30
  __classPrivateFieldSet(this, _Endpoint_middleware, new middleware_1.Middleware(), "f");
33
31
  __classPrivateFieldSet(this, _Endpoint_channels, new Set(), "f");
@@ -125,7 +123,7 @@ class Endpoint {
125
123
  }
126
124
  }
127
125
  exports.Endpoint = Endpoint;
128
- _Endpoint_middleware = new WeakMap(), _Endpoint_server = new WeakMap(), _Endpoint_channels = new WeakMap(), _Endpoint_sockets = new WeakMap(), _Endpoint_instances = new WeakSet(), _Endpoint_sendMessage = function _Endpoint_sendMessage(socket, message) {
126
+ _Endpoint_middleware = new WeakMap(), _Endpoint_channels = new WeakMap(), _Endpoint_sockets = new WeakMap(), _Endpoint_instances = new WeakSet(), _Endpoint_sendMessage = function _Endpoint_sendMessage(socket, message) {
129
127
  socket.send(JSON.stringify(message));
130
128
  }, _Endpoint_joinChannel = function _Endpoint_joinChannel(channel, socket, joinParams) {
131
129
  const cache = Object.assign(Object.assign({}, socket), { channelName: channel });
package/nest.js CHANGED
@@ -370,7 +370,7 @@ function OnJoinRequest() {
370
370
  response.send(event, rest, assigns);
371
371
  }
372
372
  else {
373
- response.accept(assigns);
373
+ response.accept(typeof assigns === 'object' ? assigns : {});
374
374
  }
375
375
  if (presence) {
376
376
  response.trackPresence(presence);
@@ -382,7 +382,9 @@ function OnJoinRequest() {
382
382
  }
383
383
  }
384
384
  catch (error) {
385
- response.reject(String(error));
385
+ if (!response.hasResponded && error instanceof Error) {
386
+ response.reject(error.message);
387
+ }
386
388
  }
387
389
  }));
388
390
  };
@@ -402,7 +404,7 @@ function OnEvent(event = '*') {
402
404
  response.send(event, rest, assigns);
403
405
  }
404
406
  else {
405
- response.accept(assigns);
407
+ response.accept(typeof assigns === 'object' ? assigns : {});
406
408
  }
407
409
  if (presence) {
408
410
  response.trackPresence(presence);
@@ -417,7 +419,9 @@ function OnEvent(event = '*') {
417
419
  }
418
420
  }
419
421
  catch (error) {
420
- response.reject(String(error));
422
+ if (!response.hasResponded && error instanceof Error) {
423
+ response.reject(error.message);
424
+ }
421
425
  }
422
426
  }));
423
427
  };
@@ -437,7 +441,7 @@ function OnConnectionRequest() {
437
441
  response.send(event, rest, assigns);
438
442
  }
439
443
  else {
440
- response.accept(assigns);
444
+ response.accept(typeof assigns === 'object' ? assigns : {});
441
445
  }
442
446
  }
443
447
  else {
@@ -446,7 +450,9 @@ function OnConnectionRequest() {
446
450
  }
447
451
  }
448
452
  catch (error) {
449
- response.reject(String(error));
453
+ if (!response.hasResponded && error instanceof Error) {
454
+ response.reject(error.message);
455
+ }
450
456
  }
451
457
  }));
452
458
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.88",
3
+ "version": "0.1.89",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -62,7 +62,7 @@ class PondSocket {
62
62
  * })
63
63
  */
64
64
  createEndpoint(path, handler) {
65
- const endpoint = new endpoint_1.Endpoint(__classPrivateFieldGet(this, _PondSocket_socketServer, "f"));
65
+ const endpoint = new endpoint_1.Endpoint();
66
66
  __classPrivateFieldGet(this, _PondSocket_middleware, "f").use((req, socket, next) => {
67
67
  const event = (0, matcher_1.parseAddress)(path, req.address);
68
68
  if (event) {