servant-websockets icon indicating copy to clipboard operation
servant-websockets copied to clipboard

Is there any way to get notified when client disconnects

Open cscalfani opened this issue 7 years ago • 1 comments

Warning: I'm fairly new to Haskell.

Right now, I assume an exception of some sort is thrown because a 500 error is returned and subsequently logged when a client disconnects.

I would like to either handle that exception myself or get notified of the disconnection. Either way, I'd rather that a 500 error wasn't sent/logged.

Thanks.

cscalfani avatar Dec 16 '17 00:12 cscalfani

I think you have to use Control.Exception (for instance finally) around function that does WS.receiveData conn.

  • websockets tutorial: https://jaspervdj.be/websockets/example/server.html
  • how I do it in one of my projects: https://github.com/turboMaCk/agile-poker/blob/master/server/AgilePoker/Data/Table.hs#L231-L246

turboMaCk avatar Jan 05 '19 14:01 turboMaCk