@eleven-am/pondsocket 0.1.29 → 0.1.31

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
@@ -9,9 +9,9 @@ class Channel {
9
9
  this._queue = [];
10
10
  this._finished = false;
11
11
  this._joinParams = params;
12
+ this._receiver = receiver;
12
13
  this._publisher = publisher;
13
14
  this._clientState = clientState;
14
- this._receiver = new subjectUtils_1.SimpleSubject();
15
15
  this._joinState = new subjectUtils_1.SimpleBehaviorSubject(false);
16
16
  this._presence = new subjectUtils_1.SimpleBehaviorSubject([]);
17
17
  this._presenceSub = this._init();
@@ -63,6 +63,7 @@ class Channel {
63
63
  */
64
64
  onMessage(callback) {
65
65
  return this._receiver.subscribe((data) => {
66
+ console.log(data.channelName, this._name, 2);
66
67
  if (data.action === enums_1.ServerActions.BROADCAST && data.channelName === this._name) {
67
68
  return callback(data.event, data.payload);
68
69
  }
package/client.js CHANGED
@@ -72,6 +72,13 @@ class PondClient {
72
72
  this._channels[name] = channel;
73
73
  return channel;
74
74
  }
75
+ /**
76
+ * @desc Subscribes to the connection state.
77
+ * @param callback - The callback to call when the state changes.
78
+ */
79
+ onConnectionChange(callback) {
80
+ return this._connectionState.subscribe(callback);
81
+ }
75
82
  _createPublisher() {
76
83
  return (message) => {
77
84
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "author": "Roy OSSAI",
23
23
  "license": "GPL-3.0",
24
- "main": "index.js",
25
- "types": "index.d.ts",
24
+ "main": "dist/index.js",
25
+ "types": "dist/index.d.ts",
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "git+https://github.com/Eleven-am/pondSocket.git"
package/types.d.ts CHANGED
@@ -18,7 +18,6 @@ type SocketCache = Pick<RequestCache, 'socket' | 'clientId' | 'assigns'>;
18
18
  type AuthorizeMiddleware = (request: JoinRequest, response: JoinResponse) => void | Promise<void>;
19
19
  type SocketMiddlewareFunction = (req: IncomingMessage, socket: internal.Duplex, head: Buffer, next: NextFunction) => void;
20
20
  export type ChannelReceivers = 'all_users' | 'all_except_sender' | string[];
21
- export type ChannelSenders = 'channel' | string;
22
21
  export type ChannelEvent = Event | PresenceEvent;
23
22
 
24
23
  interface Event {
@@ -229,6 +228,12 @@ declare class PondSocketClient {
229
228
  * @param params - The params to send to the server.
230
229
  */
231
230
  public createChannel(name: string, params?: JoinParams): Channel;
231
+
232
+ /**
233
+ * @desc Subscribes to the connection state.
234
+ * @param callback - The callback to call when the state changes.
235
+ */
236
+ public onConnectionChange (callback: (state: PondState) => void): Unsubscribe;
232
237
  }
233
238
 
234
239
  declare class AbstractRequest {
package/enums.ts DELETED
@@ -1,19 +0,0 @@
1
-
2
- export enum PresenceEventTypes {
3
- JOIN = 'JOIN',
4
- LEAVE = 'LEAVE',
5
- UPDATE = 'UPDATE'
6
- }
7
-
8
- export enum ServerActions {
9
- PRESENCE = 'PRESENCE',
10
- SYSTEM = 'SYSTEM',
11
- BROADCAST = 'BROADCAST',
12
- ERROR = 'ERROR',
13
- }
14
-
15
- export enum ClientActions {
16
- JOIN_CHANNEL = 'JOIN_CHANNEL',
17
- LEAVE_CHANNEL = 'LEAVE_CHANNEL',
18
- BROADCAST = 'BROADCAST',
19
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
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
- }