on master help sign in
Merge pull request #289 from jaspervdj/master

Bump websockets dependency to 0.9

commit66af99423c59938881db04bdaf4d33f88c83a511 authorMichael Snoyman <michael@snoyman.com> dateSun 21 Sep 2014, 18:44 (12 years ago) parent981fc4447eeb50
2 files changed+11−10
wai-websockets/Network/Wai/Handler/WebSockets.hs+10−8 wai-websockets/wai-websockets.cabal+1−2
wai-websockets/Network/Wai/Handler/WebSockets.hs+10−8
@@ -9,12 +9,13 @@ module Network.Wai.Handler.WebSockets
99
1010import Data.ByteString (ByteString)
1111import qualified Data.ByteString.Char8 as BC
12+import qualified Data.ByteString.Lazy as BL
1213import qualified Data.CaseInsensitive as CI
1314import Network.HTTP.Types (status500)
1415import qualified Network.Wai as Wai
1516import qualified Network.WebSockets as WS
1617import qualified Network.WebSockets.Connection as WS
17−import qualified System.IO.Streams as Streams
18+import qualified Network.WebSockets.Stream as WS
1819
1920--------------------------------------------------------------------------------
2021isWebSocketsReq :: Wai.Request -> Bool
@@ -62,18 +63,19 @@ runWebSockets :: WS.ConnectionOptions
6263 -> (ByteString -> IO ())
6364 -> IO a
6465runWebSockets opts req app src sink = do
65−
66− is <- Streams.makeInputStream $ do
67− bs <- src
68− return $ if BC.null bs then Nothing else Just bs
69− os <- Streams.makeOutputStream (maybe (return ()) sink) >>= Streams.builderStream
66+ stream <- WS.makeStream
67+ (do
68+ bs <- src
69+ return $ if BC.null bs then Nothing else Just bs)
70+ (\mbBl -> case mbBl of
71+ Nothing -> return ()
72+ Just bl -> mapM_ sink (BL.toChunks bl))
7073
7174 let pc = WS.PendingConnection
7275 { WS.pendingOptions = opts
7376 , WS.pendingRequest = req
7477 , WS.pendingOnAccept = \_ -> return ()
75− , WS.pendingIn = is
76− , WS.pendingOut = os
78+ , WS.pendingStream = stream
7779 }
7880
7981 app pc
wai-websockets/wai-websockets.cabal+1−2
@@ -24,8 +24,7 @@ Library
2424 , case-insensitive >= 0.2
2525 , network >= 2.2.1.5
2626 , transformers >= 0.2
27− , websockets >= 0.8
28− , io-streams >= 1.1 && < 1.2
27+ , websockets >= 0.9
2928 , http-types
3029 Exposed-modules: Network.Wai.Handler.WebSockets
3130 ghc-options: -Wall