@lzpong/httpm 1.0.1 → 1.0.2
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/httpm.js +5 -5
- package/package.json +1 -1
package/httpm.js
CHANGED
|
@@ -915,12 +915,12 @@ class WebSocket {
|
|
|
915
915
|
switch (opcode) {
|
|
916
916
|
case 0x01: { // 文本帧
|
|
917
917
|
const text = payload.toString('utf8');
|
|
918
|
-
this._emit('message', text);
|
|
918
|
+
this._emit('message', { type: 'text', data: text });
|
|
919
919
|
this._emit('text', text);
|
|
920
920
|
break;
|
|
921
921
|
}
|
|
922
922
|
case 0x02: { // 二进制帧
|
|
923
|
-
this._emit('message', payload);
|
|
923
|
+
this._emit('message', { type: 'binary', data: payload });
|
|
924
924
|
this._emit('binary', payload);
|
|
925
925
|
break;
|
|
926
926
|
}
|
|
@@ -2026,9 +2026,9 @@ class Application extends Router {
|
|
|
2026
2026
|
const sseInstance = res.sse();
|
|
2027
2027
|
const cleanup = handler(sseInstance, req);
|
|
2028
2028
|
// 连接关闭时执行清理
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
}
|
|
2029
|
+
if (typeof cleanup === 'function') {
|
|
2030
|
+
res._res.on('close', cleanup);
|
|
2031
|
+
}
|
|
2032
2032
|
});
|
|
2033
2033
|
}
|
|
2034
2034
|
|