websockets 0.1.1.5 → 0.1.2.2
raw patch · 2 files changed
+14/−9 lines, 2 filesdep ~network
Dependency ranges changed: network
Files
- Network/WebSockets.hs +12/−7
- websockets.cabal +2/−2
Network/WebSockets.hs view
@@ -211,14 +211,19 @@ hFlush h -{- | Receive a strict ByteString. Call this function only after having performed the handshake. This function will block until an entire frame is read. -}+{- | Receive a strict ByteString. Call this function only after having performed the handshake. This function will block until an entire frame is read. If the writing end of the handle is closed, the function returns an empty ByteString. -} getFrame :: Handle -> IO B.ByteString getFrame h = do- B.hGet h 1 -- assume this is 0- readUntil255 B.empty+ first <- B.hGet h 1 -- assume this is 0+ if B.null first+ then return first+ else readUntil255 B.empty where readUntil255 buf = do- b <- ((!!0) . B.unpack) `fmap` B.hGet h 1- case b of- 255 -> return buf- otherwise -> readUntil255 $ B.snoc buf b+ b <- B.hGet h 1+ if B.null b+ then return b+ else let n = (B.unpack b) !! 0+ in case n of+ 255 -> return buf+ otherwise -> readUntil255 $ B.snoc buf n
websockets.cabal view
@@ -1,5 +1,5 @@ Name: websockets-Version: 0.1.1.5+Version: 0.1.2.2 Cabal-version: >=1.6 @@ -26,6 +26,6 @@ Library Exposed-Modules: Network.WebSockets- Build-depends: pureMD5 >=2.1, network >=2.2, base ==4.*, + Build-depends: pureMD5 >=2.1, network >=2.2.3, base ==4.*, bytestring >=0.9, binary >=0.5, containers >=0.3