mirror of
https://github.com/crystelf/crystelf-core.git
synced 2025-07-04 14:49:19 +00:00
添加pong处理
This commit is contained in:
parent
6613d25d9e
commit
2b2404675e
@ -12,6 +12,7 @@ class WSMessageHandler {
|
|||||||
this.handlers = new Map([
|
this.handlers = new Map([
|
||||||
['test', this.handleTest],
|
['test', this.handleTest],
|
||||||
['ping', this.handlePing],
|
['ping', this.handlePing],
|
||||||
|
['pong', this.handlePong],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,10 @@ class WSMessageHandler {
|
|||||||
await wsTools.send(socket, { type: 'pong' });
|
await wsTools.send(socket, { type: 'pong' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async handlePong(socket: WebSocket, msg: any) {
|
||||||
|
logger.debug(`received pong ${msg.data}`);
|
||||||
|
}
|
||||||
|
|
||||||
private async handleUnknown(socket: WebSocket, msg: any) {
|
private async handleUnknown(socket: WebSocket, msg: any) {
|
||||||
logger.warn(`收到未知消息类型: ${msg.type}`);
|
logger.warn(`收到未知消息类型: ${msg.type}`);
|
||||||
await wsTools.send(socket, {
|
await wsTools.send(socket, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user