servant-websockets
servant-websockets copied to clipboard
Is there any way to get notified when client disconnects
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.
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