diff --git a/src-client/Client/Communication.hs b/src-client/Client/Communication.hs index 7f689a9..3c09b52 100644 --- a/src-client/Client/Communication.hs +++ b/src-client/Client/Communication.hs @@ -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