AuthForm: WS disconnection on successful authentication.

master
Philippe Pittoli 2023-06-02 00:53:01 +02:00
parent e44b1aebe9
commit 7804dd6647
1 changed files with 9 additions and 0 deletions

View File

@ -141,6 +141,7 @@ data Action
| HandleLoginInputUpdate String
| HandlePassInputUpdate String
| AuthenticationAttempt Event
| Finalize
| HandleWebSocket (WebSocketEvent WebSocketMessageType)
type State =
@ -161,6 +162,7 @@ component =
, eval: H.mkEval $ H.defaultEval
{ initialize = Just Initialize
, handleAction = handleAction
, finalize = Just Finalize
}
}
@ -259,6 +261,13 @@ handleAction = case _ of
Initialize ->
handleAction ConnectWebSocket
Finalize -> do
{ wsConnection } <- H.get
systemMessage "Finalize"
case wsConnection of
Nothing -> systemMessage "No socket? How is that even possible?"
Just socket -> H.liftEffect $ WS.close socket
WebSocketParseError error ->
systemMessage $ renderError (UnknownError error)