stelar-time-real 1.2.1 → 1.2.3
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/README.md +6 -0
- package/package.json +1 -1
- package/src/client.js +7 -32
- package/src/index.js +2 -3
package/README.md
CHANGED
|
@@ -558,6 +558,12 @@ client.emitBinary('upload', fileData);
|
|
|
558
558
|
|
|
559
559
|
## Changelog
|
|
560
560
|
|
|
561
|
+
### v1.2.3
|
|
562
|
+
- Cleanup: código fantasma eliminado (_parent, _children, _externalServer)
|
|
563
|
+
|
|
564
|
+
### v1.2.2
|
|
565
|
+
- Bugfix: métodos duplicados en client.js
|
|
566
|
+
|
|
561
567
|
### v1.2.0
|
|
562
568
|
- Soporte binarios: envía imágenes, archivos, audio, video sin base64
|
|
563
569
|
- `ctx.emitBinary('event', buffer)` y `client.emitBinary('event', buffer)`
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -37,6 +37,13 @@ class StelarClient {
|
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
off(event, handler) {
|
|
41
|
+
if (this.events[event] === handler) {
|
|
42
|
+
delete this.events[event];
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
onAll(handler) {
|
|
41
48
|
this._wildcardHandler = handler;
|
|
42
49
|
return this;
|
|
@@ -106,38 +113,6 @@ class StelarClient {
|
|
|
106
113
|
return this;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
setUrl(url) {
|
|
110
|
-
this.url = url;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
on(event, handler) {
|
|
115
|
-
this.events[event] = handler;
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
onAll(handler) {
|
|
120
|
-
this._wildcardHandler = handler;
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
emit(event, data) {
|
|
125
|
-
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
126
|
-
this.ws.send(JSON.stringify({ event, data }));
|
|
127
|
-
}
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
joinRoom(room) {
|
|
132
|
-
this.emit('join-room', room);
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
leaveRoom() {
|
|
137
|
-
this.emit('leave-room', {});
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
116
|
_startHeartbeat() {
|
|
142
117
|
this._hbTimer = setInterval(() => {
|
|
143
118
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
package/src/index.js
CHANGED
|
@@ -15,8 +15,6 @@ class StelarServer {
|
|
|
15
15
|
this._wildcardHandler = null;
|
|
16
16
|
this._connectionHandler = null;
|
|
17
17
|
this._acks = {};
|
|
18
|
-
this._parent = null;
|
|
19
|
-
this._children = new Map();
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
static of(path, options = {}) {
|
|
@@ -273,6 +271,7 @@ class StelarServer {
|
|
|
273
271
|
};
|
|
274
272
|
|
|
275
273
|
if (this.server) {
|
|
274
|
+
this.server._isExternal = true;
|
|
276
275
|
startServer(this.server);
|
|
277
276
|
} else {
|
|
278
277
|
const tryListen = (port) => {
|
|
@@ -300,7 +299,7 @@ class StelarServer {
|
|
|
300
299
|
stop() {
|
|
301
300
|
if (this._hbTimer) clearInterval(this._hbTimer);
|
|
302
301
|
if (this.wss) this.wss.close();
|
|
303
|
-
if (this.server && !this.
|
|
302
|
+
if (this.server && !this.server._isExternal) this.server.close();
|
|
304
303
|
return this;
|
|
305
304
|
}
|
|
306
305
|
}
|