@eleven-am/pondsocket 0.1.26 → 0.1.28

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/client/channel.js CHANGED
@@ -50,7 +50,7 @@ class Channel {
50
50
  * @param event - The event to monitor.
51
51
  * @param callback - The callback to call when a message is received.
52
52
  */
53
- onMessage(event, callback) {
53
+ onMessageEvent(event, callback) {
54
54
  return this._receiver.subscribe((data) => {
55
55
  if (data.action === enums_1.ServerActions.BROADCAST && data.event === event && data.channelName === this._name) {
56
56
  return callback(data.payload);
@@ -61,7 +61,7 @@ class Channel {
61
61
  * @desc Monitors the channel for messages.
62
62
  * @param callback - The callback to call when a message is received.
63
63
  */
64
- onMessageEvent(callback) {
64
+ onMessage(callback) {
65
65
  return this._receiver.subscribe((data) => {
66
66
  if (data.action === enums_1.ServerActions.BROADCAST && data.channelName === this._name) {
67
67
  return callback(data.event, data.payload);
package/client.js CHANGED
@@ -75,7 +75,7 @@ class PondClient {
75
75
  _createPublisher() {
76
76
  return (message) => {
77
77
  var _a;
78
- if (((_a = this._socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN) {
78
+ if (((_a = this._socket) === null || _a === void 0 ? void 0 : _a.readyState) === 1) {
79
79
  this._socket.send(JSON.stringify(message));
80
80
  }
81
81
  };
package/node.js CHANGED
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const ws_1 = require("ws");
7
6
  const client_1 = __importDefault(require("./client"));
7
+ const WebSocket = require('websocket').w3cwebsocket;
8
8
  class PondClient extends client_1.default {
9
9
  /**
10
10
  * @desc Connects to the server and returns the socket.
11
11
  */
12
12
  connect(backoff = 1) {
13
- const socket = new ws_1.WebSocket(this._address.toString());
13
+ const socket = new WebSocket(this._address.toString());
14
14
  socket.onopen = () => {
15
15
  this._connectionState.publish('OPEN');
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -28,12 +28,14 @@
28
28
  "url": "git+https://github.com/Eleven-am/pondSocket.git"
29
29
  },
30
30
  "dependencies": {
31
+ "websocket": "^1.0.34",
31
32
  "ws": "^8.12.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/express": "^4.17.14",
35
36
  "@types/jest": "^29.5.0",
36
37
  "@types/node": "^16.10.3",
38
+ "@types/websocket": "^1.0.5",
37
39
  "@types/ws": "^8.5.3",
38
40
  "@typescript-eslint/eslint-plugin": "^5.58.0",
39
41
  "eslint": "^8.38.0",
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2015",
4
+ "module": "commonjs",
5
+ "declaration": false,
6
+ "outDir": "./dist",
7
+ "esModuleInterop": true,
8
+ "strict": true,
9
+ },
10
+ "include": ["src"],
11
+ "exclude": ["node_modules", "**/__tests__/*"]
12
+ }
package/types.d.ts CHANGED
@@ -129,13 +129,13 @@ export declare class Channel {
129
129
  * @param event - The event to monitor.
130
130
  * @param callback - The callback to call when a message is received.
131
131
  */
132
- public onMessage(event: string, callback: (message: PondMessage) => void): Unsubscribe;
132
+ public onMessageEvent(event: string, callback: (message: PondMessage) => void): Unsubscribe;
133
133
 
134
134
  /**
135
135
  * @desc Monitors the channel for messages.
136
136
  * @param callback - The callback to call when a message is received.
137
137
  */
138
- public onMessageEvent(callback: (event: string, message: PondMessage) => void): Unsubscribe;
138
+ public onMessage(callback: (event: string, message: PondMessage) => void): Unsubscribe;
139
139
 
140
140
  /**
141
141
  * @desc Monitors the connection state of the channel.
@@ -538,3 +538,4 @@ declare class PondSocket {
538
538
  * @constructor
539
539
  */
540
540
  declare const PondSocketFromExpress: (app: Express) => PondSocketExpressApp;
541
+
File without changes