solving quitting issue in client
This commit is contained in:
parent
58120fbc1b
commit
540874917c
1 changed files with 4 additions and 4 deletions
|
@ -53,7 +53,7 @@ sendMessage st msg sock = do
|
||||||
(\ptr -> do
|
(\ptr -> do
|
||||||
eResult <- try $ sendBuf sock ptr (VS.length msgVector)
|
eResult <- try $ sendBuf sock ptr (VS.length msgVector)
|
||||||
case eResult of
|
case eResult of
|
||||||
Left (_ :: IOException) -> gracefulExit st "Quitting due to connection loss…"
|
Left (_ :: IOException) -> gracefulExit st "sendMessage: Quitting due to connection loss…"
|
||||||
Right _ -> pure ()
|
Right _ -> pure ()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ handleMessages = do
|
||||||
msgs <- liftIO $ STM.atomically $ STM.flushTQueue queue
|
msgs <- liftIO $ STM.atomically $ STM.flushTQueue queue
|
||||||
mapM_
|
mapM_
|
||||||
(\msg -> do
|
(\msg -> do
|
||||||
liftIO $ print msg
|
liftIO $ putStrLn $ "handling following: " <> show msg
|
||||||
handleMessage msg
|
handleMessage msg
|
||||||
)
|
)
|
||||||
msgs
|
msgs
|
||||||
|
@ -153,14 +153,14 @@ terminateGameOnSigint = do
|
||||||
void $ liftIO $ installHandler
|
void $ liftIO $ installHandler
|
||||||
keyboardSignal
|
keyboardSignal
|
||||||
(CatchOnce $ do
|
(CatchOnce $ do
|
||||||
putStrLn "SIGINT caught, terminating…"
|
putStrLn "receiveMessage: SIGINT caught, terminating…"
|
||||||
STM.atomically $ do
|
STM.atomically $ do
|
||||||
currentState <- STM.readTMVar clientState
|
currentState <- STM.readTMVar clientState
|
||||||
void $ STM.swapTMVar clientState $ currentState { clientStop = True }
|
void $ STM.swapTMVar clientState $ currentState { clientStop = True }
|
||||||
-- Vty.shutdown (clientVty currentState)
|
-- Vty.shutdown (clientVty currentState)
|
||||||
partingMessage st clientId sock
|
partingMessage st clientId sock
|
||||||
-- Raise SIGINT again so it does not get blocked
|
-- Raise SIGINT again so it does not get blocked
|
||||||
-- raiseSignal keyboardSignal
|
raiseSignal keyboardSignal
|
||||||
)
|
)
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue