Skip to content

Commit

Permalink
Command loop working
Browse files Browse the repository at this point in the history
  • Loading branch information
ckkashyap committed Nov 10, 2010
1 parent 8a9f958 commit 45502a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 1 addition & 2 deletions RFB/ClientToServer.hs
Expand Up @@ -15,8 +15,7 @@ clientCutText = 6 :: Word8


bytesToRead :: Word8 -> Int
bytesToRead c = 19
--bytesToRead c = length (commandFormat c) -- excluding the command byte
bytesToRead c = foldr (+) 0 (map (\x -> if x == 0 then 1 else x) (commandFormat c))



Expand Down
30 changes: 27 additions & 3 deletions RFB/CommandLoop.hs
Expand Up @@ -15,8 +15,32 @@ commandLoop handle = do
commandByte <- BS.hGet handle 1
let command = runGet (do {x<-getWord8;return(x);}) commandByte
byteStream <- BS.hGet handle (RFBClient.bytesToRead command)
let x = RFBClient.parseCommandByteString byteStream command
putStrLn (show x)
return ()
let commandData = RFBClient.parseCommandByteString byteStream command
case command of
0 -> processSetPixelFormat commandData
2 -> processSetEncodings handle commandData
_ -> putStrLn "Some other command"

commandLoop handle



processSetPixelFormat (bpp:
depth:
bigEndian:
trueColor:
redMax:
greenMax:
blueMax:
redShift:
greenShift:
blueShift:[]) = do
putStrLn "SetPixelFormat Command"
putStrLn ("BPP = " ++ (show bpp))


processSetEncodings handle [count] = do
putStrLn "SetEncodings Command"
putStrLn (show count)
x <- BS.hGet handle (4*count)
return ()

0 comments on commit 45502a5

Please sign in to comment.