@kevisual/router 0.0.44 → 0.0.45
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/dist/router.js +3 -2
- package/package.json +1 -1
- package/src/server/server-bun.ts +3 -2
package/dist/router.js
CHANGED
|
@@ -6664,7 +6664,7 @@ class BunServer extends ServerBase {
|
|
|
6664
6664
|
},
|
|
6665
6665
|
websocket: {
|
|
6666
6666
|
open: (ws) => {
|
|
6667
|
-
ws.send({ type: 'connected' });
|
|
6667
|
+
ws.send(JSON.stringify({ type: 'connected' }));
|
|
6668
6668
|
},
|
|
6669
6669
|
message: async (ws, message) => {
|
|
6670
6670
|
const pathname = ws.data.pathname || '';
|
|
@@ -6676,9 +6676,10 @@ class BunServer extends ServerBase {
|
|
|
6676
6676
|
// WebSocket 连接关闭
|
|
6677
6677
|
const id = ws?.data?.id || '';
|
|
6678
6678
|
if (id) {
|
|
6679
|
-
this.emitter.emit(id, { type: 'close', ws, id });
|
|
6679
|
+
this.emitter.emit('close--' + id, { type: 'close', ws, id });
|
|
6680
6680
|
setTimeout(() => {
|
|
6681
6681
|
// 关闭后 5 秒清理监听器, 避免内存泄漏, 理论上原本的自己就应该被清理掉了,这里是保险起见
|
|
6682
|
+
this.emitter.removeAllListeners('close--' + id);
|
|
6682
6683
|
this.emitter.removeAllListeners(id);
|
|
6683
6684
|
}, 5000);
|
|
6684
6685
|
}
|
package/package.json
CHANGED
package/src/server/server-bun.ts
CHANGED
|
@@ -223,7 +223,7 @@ export class BunServer extends ServerBase implements ServerType {
|
|
|
223
223
|
},
|
|
224
224
|
websocket: {
|
|
225
225
|
open: (ws: any) => {
|
|
226
|
-
ws.send({ type: 'connected' });
|
|
226
|
+
ws.send(JSON.stringify({ type: 'connected' }));
|
|
227
227
|
},
|
|
228
228
|
message: async (ws: any, message: string | Buffer) => {
|
|
229
229
|
const pathname = ws.data.pathname || '';
|
|
@@ -235,9 +235,10 @@ export class BunServer extends ServerBase implements ServerType {
|
|
|
235
235
|
// WebSocket 连接关闭
|
|
236
236
|
const id = ws?.data?.id || '';
|
|
237
237
|
if (id) {
|
|
238
|
-
this.emitter.emit(id, { type: 'close', ws, id });
|
|
238
|
+
this.emitter.emit('close--' + id, { type: 'close', ws, id });
|
|
239
239
|
setTimeout(() => {
|
|
240
240
|
// 关闭后 5 秒清理监听器, 避免内存泄漏, 理论上原本的自己就应该被清理掉了,这里是保险起见
|
|
241
|
+
this.emitter.removeAllListeners('close--' + id);
|
|
241
242
|
this.emitter.removeAllListeners(id);
|
|
242
243
|
}, 5000);
|
|
243
244
|
}
|