diff options
Diffstat (limited to 'KikiD')
-rw-r--r-- | KikiD/Message.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/KikiD/Message.hs b/KikiD/Message.hs index c4903cc..5b642f3 100644 --- a/KikiD/Message.hs +++ b/KikiD/Message.hs | |||
@@ -5,14 +5,18 @@ import qualified KikiD.GetLine | |||
5 | import qualified Data.ByteString.Char8 as B | 5 | import qualified Data.ByteString.Char8 as B |
6 | import Data.Monoid | 6 | import Data.Monoid |
7 | import Text.Read | 7 | import Text.Read |
8 | import Data.Char (ord) | ||
9 | import Control.Monad | ||
8 | 10 | ||
9 | data KikiDMessage = TODO deriving (Show,Read) | 11 | data KikiDMessage = TODO deriving (Show,Read) |
10 | 12 | ||
11 | instance Serialize KikiDMessage where | 13 | instance Serialize KikiDMessage where |
12 | put = putByteString . B.pack . show | 14 | put m = mapM_ (putWord8 . fromIntegral . ord) "TODO" |
15 | -- putByteString . B.pack $ show m ++ "\n" | ||
13 | get = do | 16 | get = do |
14 | x <- KikiD.GetLine.getLine | 17 | t <- getWord8 |
15 | case (readEither (B.unpack x) :: Either String KikiDMessage) of | 18 | o <- getWord8 |
16 | Right m -> return m | 19 | d <- getWord8 |
17 | Left er -> fail ("PARSE ERROR: " <> er) | 20 | o <- getWord8 |
21 | return TODO | ||
18 | 22 | ||