angelia.io 3.4.80 → 3.4.81

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,7 +1,9 @@
1
1
  {
2
2
  "name": "angelia.io",
3
- "version": "3.4.80",
3
+ "version": "3.4.81",
4
4
  "description": "WebSockets Server and Client API for node.js and the browser, with rooms support.",
5
+ "author": "@titoBouzout @boredofnames",
6
+ "license": "GPL",
5
7
  "homepage": "https://github.com/titoBouzout/angelia.io",
6
8
  "repository": {
7
9
  "type": "git",
@@ -9,6 +11,22 @@
9
11
  },
10
12
  "type": "module",
11
13
  "main": "index.js",
14
+ "dependencies": {
15
+ "bufferutil": "^4.0.3",
16
+ "is-class": "^0.0.9",
17
+ "isobject": "^4.0.0",
18
+ "to-fast-properties": "^3.0.1",
19
+ "utf-8-validate": "^6.x.x",
20
+ "ws": "^8.x.x"
21
+ },
22
+ "exports": {
23
+ "./server": {
24
+ "default": "./server/Server.js"
25
+ },
26
+ "./client": {
27
+ "default": "./client/index.js"
28
+ }
29
+ },
12
30
  "keywords": [
13
31
  "Client",
14
32
  "Server",
@@ -25,16 +43,6 @@
25
43
  "io",
26
44
  "ws"
27
45
  ],
28
- "author": "@titoBouzout @boredofnames",
29
- "license": "GPL",
30
- "dependencies": {
31
- "bufferutil": "^4.0.3",
32
- "is-class": "^0.0.9",
33
- "isobject": "^4.0.0",
34
- "to-fast-properties": "^3.0.1",
35
- "utf-8-validate": "^5.0.4",
36
- "ws": "^8.x.x"
37
- },
38
46
  "prettier": {
39
47
  "printWidth": 70,
40
48
  "useTabs": true,
package/server/Server.js CHANGED
@@ -13,7 +13,7 @@ import fs from 'node:fs'
13
13
  import * as http from 'http'
14
14
  import * as https from 'https'
15
15
 
16
- import WebSocket, { WebSocketServer } from 'ws'
16
+ import WebSocket, { WebSocketServer, Sender } from 'ws'
17
17
 
18
18
  class ServerSingleton {
19
19
  constructor() {
@@ -65,6 +65,7 @@ class ServerSingleton {
65
65
  cache: Object.create(null),
66
66
 
67
67
  URL: url,
68
+ Sender,
68
69
  Socket,
69
70
  WebSocket,
70
71
  WebSocketServer,
@@ -88,11 +89,8 @@ class ServerSingleton {
88
89
  },
89
90
  })
90
91
 
91
- this.pingData = this.WebSocket.Sender.frame(
92
- Buffer.from(''),
93
- this.WebSocketFrame,
94
- )
95
- this.disconnectData = this.WebSocket.Sender.frame(
92
+ this.pingData = this.Sender.frame(Buffer.from(''), this.WebSocketFrame)
93
+ this.disconnectData = this.Sender.frame(
96
94
  Buffer.from(JSON.stringify([['disconnect', true]])),
97
95
  this.WebSocketFrame,
98
96
  )
@@ -292,7 +290,7 @@ class ServerSingleton {
292
290
  let json = JSON.stringify(messages)
293
291
  this.bytesSent += json.length
294
292
  socket.bytesSent += json.length
295
- this.cache[id] = this.WebSocket.Sender.frame(
293
+ this.cache[id] = this.Sender.frame(
296
294
  Buffer.from(json),
297
295
  this.WebSocketFrame,
298
296
  )
@@ -520,6 +518,6 @@ class ServerSingleton {
520
518
  }
521
519
  }
522
520
 
523
- const Server = new ServerSingleton()
521
+ export const Server = new ServerSingleton()
524
522
 
525
- export { Server, Server as default }
523
+ export { Room, Server as default }
package/server/Socket.js CHANGED
@@ -94,7 +94,9 @@ export class Socket {
94
94
  this.io.on('error', this.onerror)
95
95
  this.io.on('message', this.onmessage)
96
96
  }
97
- onclose(code, message) {
97
+ onclose(code, message, isBinary) {
98
+ message = message.toString()
99
+
98
100
  this.server.sockets.delete(this)
99
101
 
100
102
  for (let room of this.rooms) {
@@ -136,7 +138,9 @@ export class Socket {
136
138
  return false
137
139
  }
138
140
  }
139
- onmessage(e) {
141
+ onmessage(e, isBinary) {
142
+ e = isBinary ? e.toString() : e
143
+
140
144
  if (e === '') {
141
145
  this.server.pong(this)
142
146
  } else {