client send pong

This commit is contained in:
nek0 2024-02-02 15:48:55 +01:00
parent 9d140b6206
commit dda1389e42

View file

@ -74,6 +74,16 @@ handleMessage ServerQuit = do
}
liftIO $ putStrLn "Quitting due to server shutdown"
handleMessage (Ping id') = do
cid <- asks rcClientUUID
sock <- asks rcSocket
liftIO $ sendMessage
( ClientMessage
cid
(Pong id')
)
sock
handleMessage (TickUpdate slice wizard) = do
modify' (\st@(StateContainer {}) ->
st
@ -94,7 +104,10 @@ receiveMessage sock queue = do
ptr <- mallocArray maxBufferLength
bufferLength <- recvBuf sock ptr maxBufferLength
rawMsg <- B.pack <$> peekArray bufferLength ptr
let msgs = map B8.tail $ init $ B8.split '>' $ B8.fromStrict rawMsg
let msgs =
if B.length rawMsg < 1
then []
else map B8.tail $ init $ B8.split '>' $ B8.fromStrict rawMsg
mapM_
(\msg -> do
let mJsonMsg = A.decode' msg