Skip to content

Commit

Permalink
fix: don send ping message
Browse files Browse the repository at this point in the history
  • Loading branch information
hxg2050 committed Feb 25, 2024
1 parent a8610f8 commit 009ec50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "feiyun",
"private": false,
"version": "0.2.0",
"version": "0.2.1",
"repository": "https://github.com/hxg2050/feiyun.git",
"license": "MIT",
"main": "./dist/index.cjs",
Expand Down
9 changes: 7 additions & 2 deletions src/server/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ export const createWebsocketServer = (options: {port?: number, timeout?: number}
openHandler && openHandler(ws);
},
message(ws, message) {
message === 'ping' && options.timeout && ping(ws);
messageHandler && messageHandler(ws, message);
if (message === 'ping') {
if (options.timeout) {
ping(ws);
}
} else{
messageHandler && messageHandler(ws, message);
}
},
close(ws) {
ws.unsubscribe(ALL);
Expand Down

0 comments on commit 009ec50

Please sign in to comment.