solving quitting issue in client

This commit is contained in:
nek0 2024-04-05 16:24:46 +02:00
parent 58120fbc1b
commit 540874917c

View file

@ -53,7 +53,7 @@ sendMessage st msg sock = do
(\ptr -> do
eResult <- try $ sendBuf sock ptr (VS.length msgVector)
case eResult of
Left (_ :: IOException) -> gracefulExit st "Quitting due to connection loss…"
Left (_ :: IOException) -> gracefulExit st "sendMessage: Quitting due to connection loss…"
Right _ -> pure ()
)
@ -64,7 +64,7 @@ handleMessages = do
msgs <- liftIO $ STM.atomically $ STM.flushTQueue queue
mapM_
(\msg -> do
liftIO $ print msg
liftIO $ putStrLn $ "handling following: " <> show msg
handleMessage msg
)
msgs
@ -153,14 +153,14 @@ terminateGameOnSigint = do
void $ liftIO $ installHandler
keyboardSignal
(CatchOnce $ do
putStrLn "SIGINT caught, terminating…"
putStrLn "receiveMessage: SIGINT caught, terminating…"
STM.atomically $ do
currentState <- STM.readTMVar clientState
void $ STM.swapTMVar clientState $ currentState { clientStop = True }
-- Vty.shutdown (clientVty currentState)
partingMessage st clientId sock
-- Raise SIGINT again so it does not get blocked
-- raiseSignal keyboardSignal
raiseSignal keyboardSignal
)
Nothing