add keepalive ping, onclose event reason
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -159,6 +159,16 @@ ws.on("upgrade", () => { | ||||
|   ); | ||||
| }); | ||||
|  | ||||
| ws.on("close", (event: CloseEvent) => { | ||||
|   console.log(`Connection closed: ${event.reason}`); | ||||
| }); | ||||
|  | ||||
| ws.on("open", () => { | ||||
|   setInterval(() => { | ||||
|     ws.send(JSON.stringify({ type: "ping" })); | ||||
|   }, 20000); | ||||
| }); | ||||
|  | ||||
| ws.on("message", async (data) => { | ||||
|   try { | ||||
|     const message: WSEvent = JSON.parse(data.toString("utf-8")); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user