angelia.io 2.4.72 → 2.4.75
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 +1 -50
- package/readme.md +2 -2
- package/server/Server.js +17 -7
- package/server/rooms/Room.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angelia.io",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.75",
|
|
4
4
|
"description": "WebSockets Server and Client API for node.js and the browser, with rooms support.",
|
|
5
5
|
"homepage": "https://github.com/titoBouzout/angelia.io",
|
|
6
6
|
"repository": {
|
|
@@ -46,54 +46,5 @@
|
|
|
46
46
|
"arrowParens": "avoid",
|
|
47
47
|
"quoteProps": "preserve",
|
|
48
48
|
"proseWrap": "preserve"
|
|
49
|
-
},
|
|
50
|
-
"eslintConfig": {
|
|
51
|
-
"env": {
|
|
52
|
-
"browser": true,
|
|
53
|
-
"node": true,
|
|
54
|
-
"es6": true
|
|
55
|
-
},
|
|
56
|
-
"parser": "babel-eslint",
|
|
57
|
-
"extends": "eslint:recommended",
|
|
58
|
-
"parserOptions": {
|
|
59
|
-
"ecmaFeatures": {
|
|
60
|
-
"experimentalObjectRestSpread": true,
|
|
61
|
-
"jsx": true,
|
|
62
|
-
"impliedStrict": true,
|
|
63
|
-
"es6": true
|
|
64
|
-
},
|
|
65
|
-
"es6": true,
|
|
66
|
-
"ecmaVersion": 6,
|
|
67
|
-
"sourceType": "module",
|
|
68
|
-
"allowImportExportEverywhere": false,
|
|
69
|
-
"codeFrame": false
|
|
70
|
-
},
|
|
71
|
-
"plugins": [
|
|
72
|
-
"react"
|
|
73
|
-
],
|
|
74
|
-
"rules": {
|
|
75
|
-
"comma-dangle": "off",
|
|
76
|
-
"indent": "off",
|
|
77
|
-
"linebreak-style": [
|
|
78
|
-
"error",
|
|
79
|
-
"unix"
|
|
80
|
-
],
|
|
81
|
-
"no-cond-assign": "off",
|
|
82
|
-
"no-console": "off",
|
|
83
|
-
"no-empty": "off",
|
|
84
|
-
"no-extra-boolean-cast": "off",
|
|
85
|
-
"no-extra-semi": "off",
|
|
86
|
-
"no-fallthrough": "off",
|
|
87
|
-
"no-func-assign": "off",
|
|
88
|
-
"no-inner-declarations": "off",
|
|
89
|
-
"no-mixed-spaces-and-tabs": "off",
|
|
90
|
-
"no-redeclare": "off",
|
|
91
|
-
"no-tabs": "off",
|
|
92
|
-
"no-undef": "off",
|
|
93
|
-
"no-global-assign": "off",
|
|
94
|
-
"no-unreachable": "off",
|
|
95
|
-
"no-unused-vars": "off",
|
|
96
|
-
"strict": "off"
|
|
97
|
-
}
|
|
98
49
|
}
|
|
99
50
|
}
|
package/readme.md
CHANGED
|
@@ -90,6 +90,7 @@ Server.listen({
|
|
|
90
90
|
| `cert` | String | '' | path to the cert file for using https fullchain.pem |
|
|
91
91
|
| `key` | String | '' | path to the key file for using https privkey.pem |
|
|
92
92
|
| `http` | node server | null | in case you want to use your own server. Else one will be created, as in `require('http(s)').createServer()` |
|
|
93
|
+
| `timeout` | Number | 60000 | time in milliseconds after a socket is considered gone, minimun value is 10000 |
|
|
93
94
|
|
|
94
95
|
### Server Object
|
|
95
96
|
|
|
@@ -155,7 +156,7 @@ import Server from 'angelia.io/server'
|
|
|
155
156
|
|
|
156
157
|
class _ {
|
|
157
158
|
connect(socket, request) {
|
|
158
|
-
console.log(socket,
|
|
159
|
+
console.log(socket, request)
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
Server.on(_)
|
|
@@ -365,7 +366,6 @@ As in `socket.on('connect', () => console.log('connect happened!'))`
|
|
|
365
366
|
| `connect` | **this happens only once** when we connect to the server, any future connection is a `reconnect` |
|
|
366
367
|
| `reconnect` | if we were connected at least once, then any reconnection will dispatch this event instead of `connect` |
|
|
367
368
|
| `disconnect` | when we disconnect from the server |
|
|
368
|
-
| |
|
|
369
369
|
|
|
370
370
|
</details>
|
|
371
371
|
|
package/server/Server.js
CHANGED
|
@@ -97,12 +97,14 @@ class ServerSingleton {
|
|
|
97
97
|
|
|
98
98
|
since: Date.now(),
|
|
99
99
|
now: Date.now(),
|
|
100
|
+
timeout: +options.timeout >= 10000 ? +options.timeout : this.timeout,
|
|
100
101
|
})
|
|
102
|
+
this.timeoutCheck = this.timeout / 2
|
|
101
103
|
|
|
102
104
|
this.ensureFastProperties()
|
|
103
105
|
|
|
104
106
|
// updates ping and checks for disconnections
|
|
105
|
-
setInterval(this.ping,
|
|
107
|
+
setInterval(this.ping, this.timeoutCheck)
|
|
106
108
|
setInterval(this.updateNow, 500)
|
|
107
109
|
|
|
108
110
|
// fires the server
|
|
@@ -145,9 +147,9 @@ class ServerSingleton {
|
|
|
145
147
|
if (!io.closing) {
|
|
146
148
|
io.closing = true
|
|
147
149
|
if (options.debug) {
|
|
148
|
-
console.log('Server Shutting Down\n', this)
|
|
150
|
+
console.log('Socket Server Shutting Down\n', this)
|
|
149
151
|
} else {
|
|
150
|
-
console.log('Server Shutting Down\n')
|
|
152
|
+
console.log('Socket Server Shutting Down\n')
|
|
151
153
|
}
|
|
152
154
|
io.close()
|
|
153
155
|
if (options.debug) {
|
|
@@ -217,8 +219,6 @@ class ServerSingleton {
|
|
|
217
219
|
|
|
218
220
|
// PRIVATE API
|
|
219
221
|
onconnect(socket, request) {
|
|
220
|
-
this.updateNow()
|
|
221
|
-
|
|
222
222
|
socket = new this.Socket(socket, this)
|
|
223
223
|
|
|
224
224
|
// set the ip, userAgent and params
|
|
@@ -305,8 +305,18 @@ class ServerSingleton {
|
|
|
305
305
|
socket.timedout = true
|
|
306
306
|
this.events.timeout && this.events.timeout(socket.proxy, delay)
|
|
307
307
|
socket.io.terminate()
|
|
308
|
-
} else {
|
|
309
|
-
|
|
308
|
+
} else if (delay > this.timeoutCheck - 5000) {
|
|
309
|
+
/*
|
|
310
|
+
in an example:
|
|
311
|
+
if timeout is set to 60 seeconds
|
|
312
|
+
then we check for timed out sockets every 30 seconds
|
|
313
|
+
if the socket was last seen 29 seconds ago
|
|
314
|
+
then the next check will be in another 30 seconds
|
|
315
|
+
that means that if the socket doesnt sends any message
|
|
316
|
+
then the last seen will be 59 seconds the next time
|
|
317
|
+
this gives very little amount of time to check
|
|
318
|
+
for this reason we remove 5 seconds on the condition
|
|
319
|
+
*/
|
|
310
320
|
this.pingSocket(socket)
|
|
311
321
|
}
|
|
312
322
|
}
|
package/server/rooms/Room.js
CHANGED