drashland/wocket

Wocket Doesn't Send A `disconnect`Event When A Client Disconnects

ebebbington opened this issue · 0 comments

Summary

When a connected client (from the browser) connects to a websocket server that uses Wocket, everything is fine. But when the client disconnects (eg refreshes the page), the internals of Wocket. doesn't senda disconnect event. But it. should because. it's part o f the. reserved event names. Eg:

// this is never called
wsServer.on("disconnect",  (data: Packet) => {
})

Steps To Reproduce The Bug

  1. Create a websocket server using wocket
  2. Create handlers for the connect and disconnect events (add logging)
  3. Create a websocket client from the browser
  4. Refresh the page
  5. See that the disconnect handler is never called

Expected Behavior

When a client disconnects, the disconnect event should be called

Suggested Solution(s)

Send this when there is a disconnection