small fixes

This commit is contained in:
nek0 2023-12-12 11:52:25 +01:00
parent 7339587bd1
commit 007cf8e3f3

View file

@ -5,8 +5,6 @@ import Control.Concurrent (threadDelay)
import qualified Control.Concurrent.STM as STM import qualified Control.Concurrent.STM as STM
import Control.Monad (void)
import Control.Monad.RWS import Control.Monad.RWS
import qualified Data.Aeson as A import qualified Data.Aeson as A
@ -14,8 +12,6 @@ import qualified Data.Aeson as A
import qualified Data.ByteString as B import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy.Char8 as B8 import qualified Data.ByteString.Lazy.Char8 as B8
import Data.Maybe (fromJust)
import qualified Data.Vector.Storable as VS import qualified Data.Vector.Storable as VS
import Foreign hiding (void) import Foreign hiding (void)
@ -75,7 +71,9 @@ terminateGameOnSigint = do
void $ liftIO $ installHandler void $ liftIO $ installHandler
keyboardSignal keyboardSignal
(CatchOnce $ do (CatchOnce $ do
currentState <- STM.atomically $ STM.readTMVar clientState STM.atomically $ do
currentState <- STM.readTMVar clientState
void $ STM.swapTMVar clientState $ currentState { clientStop = True }
threadDelay (10 ^ 6) threadDelay (10 ^ 6)
sendMessage (ClientMessage clientId ClientQuit) sock sendMessage (ClientMessage clientId ClientQuit) sock
close sock close sock