just-another-http-api 1.2.7 → 1.2.8

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": "just-another-http-api",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "A framework built on top of fastify aimed at removing the need for any network or server configuration. ",
5
5
  "homepage": "https://github.com/OllieEdge/just-another-http-api#readme",
6
6
  "repository": {
@@ -32,14 +32,14 @@ class WebsocketGroup {
32
32
 
33
33
  #broadcastMessageToClients ( message ) {
34
34
  this.connections.forEach ( conn => {
35
- conn.socket.send ( typeof message === 'string' ? message : JSON.stringify ( message ) );
35
+ conn.send ( typeof message === 'string' ? message : JSON.stringify ( message ) );
36
36
  } );
37
37
  }
38
38
 
39
39
  #handleIndividualMessage ( individualMessage ) {
40
40
  const { connectionId, message } = JSON.parse ( individualMessage );
41
41
  if(this.connections.has(connectionId)) {
42
- this.connections.get(connectionId).socket.send(message);
42
+ this.connections.get(connectionId).send(message);
43
43
  }
44
44
  }
45
45
 
@@ -51,7 +51,7 @@ class WebsocketGroup {
51
51
  }
52
52
  else{
53
53
  connection.isAlive = false;
54
- connection.socket.ping ();
54
+ connection.ping ();
55
55
  }
56
56
  } );
57
57
  }
@@ -72,7 +72,7 @@ class WebsocketGroup {
72
72
  connection.isAlive = true;
73
73
  this.connections.set ( connectionId, connection );
74
74
 
75
- connection.socket.on ( 'message', async message => {
75
+ connection.on ( 'message', async message => {
76
76
  const userMessage = {
77
77
  groupName: this.groupName,
78
78
  connectionId,
@@ -81,16 +81,16 @@ class WebsocketGroup {
81
81
  await redis.publish ( `${this.groupName}_messageReceived`, JSON.stringify ( userMessage ) );
82
82
  } );
83
83
 
84
- connection.socket.on ( 'close', () => {
84
+ connection.on ( 'close', () => {
85
85
  this.connections.delete ( connectionId );
86
86
  this.#clean(connectionId);
87
87
  } );
88
88
 
89
- connection.socket.on ( 'pong', () => {
89
+ connection.on ( 'pong', () => {
90
90
  connection.isAlive = true;
91
91
  } );
92
92
 
93
- connection.socket.on ( 'error', error => {
93
+ connection.on ( 'error', error => {
94
94
  console.error ( 'WebSocket error:', error );
95
95
  this.connections.delete ( connectionId );
96
96
  this.#clean(connectionId);