packages feed

hemokit 0.5 → 0.5.1

raw patch · 4 files changed

+15/−16 lines, 4 filesdep ~websockets

Dependency ranges changed: websockets

Files

apps/DumpConduit.hs view
@@ -116,12 +116,12 @@           -- Print to stdout or serve via websockets? Show the datatype or format via JSON?           let outputSink :: (ToJSON i, Show i) => Sink i IO ()               outputSink = case serve of-                Nothing           | json      -> asJson $ CL.mapM_ BSL8.putStrLn-                                  | otherwise ->          CL.mapM_ print-                Just (host, port) | json      -> asJson $ websocketSink host port-                                  | otherwise ->          websocketSink host port+                Nothing           | json      -> asJson =$ CL.mapM_ BSL8.putStrLn+                                  | otherwise ->           CL.mapM_ print+                Just (host, port) | json      -> asJson =$ websocketSink host port+                                  | otherwise ->           websocketSink host port                 where-                  asJson = mapInput encode (const Nothing)+                  asJson = CL.map encode                throttled = if realtime then ($= throttle) else id 
apps/WebsocketUtils.hs view
@@ -9,17 +9,16 @@  import           Control.Concurrent import           Control.Monad-import           Control.Monad.IO.Class import           Data.Aeson (ToJSON(..), encode) import           Network.WebSockets   -- | A websocket server that serves JSON from a Chan.-jsonWSServerFromChan :: (ToJSON a) => Chan a -> (Request -> WebSockets Hybi10 ())+jsonWSServerFromChan :: (ToJSON a) => Chan a -> PendingConnection -> IO () jsonWSServerFromChan chan = \req -> do-  acceptRequest req-  c <- liftIO $ dupChan chan-  forever (liftIO (readChan c) >>= sendTextData . encode)+  conn <- acceptRequest req+  c <- dupChan chan+  forever (readChan c >>= sendTextData conn . encode)   -- | Creates and starts (forking) a JSON-serving websocket server.
hemokit.cabal view
@@ -1,5 +1,5 @@ name:          hemokit-version:       0.5+version:       0.5.1 license:       MIT copyright:     2013 Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com> author:        Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com>@@ -59,7 +59,7 @@     , mtl                    >= 2.1.2     , optparse-applicative   >= 0.5.2.1     , vector                 >= 0.9-    , websockets             >= 0.7.3.0+    , websockets             >= 0.8.0.0   hs-source-dirs:     src   default-language: Haskell2010@@ -100,7 +100,7 @@     , split                  >= 0.2.2     , time                   >= 1.4.0.1     , transformers           >= 0.3.0.0-    , websockets             >= 0.7.3.0+    , websockets             >= 0.8.0.0   ghc-options: -Wall  
src/Hemokit/Conduit.hs view
@@ -44,10 +44,10 @@   chan <- liftIO $ newChan    -- Server loop: Send what comes in via the chan; Nothing shuts down-  let jsonWSServerFromChan :: WS.Request -> WS.WebSockets WS.Hybi10 ()+  let jsonWSServerFromChan :: WS.PendingConnection  -> IO ()       jsonWSServerFromChan = \req -> do-        WS.acceptRequest req-        void $ untilNothing (liftIO (readChan chan)) (WS.sendTextData . encode)+        conn <- WS.acceptRequest req+        void $ untilNothing (readChan chan) (WS.sendTextData conn . encode)    -- Fork off Websocket server   _ <- liftIO $ forkIO $ WS.runServer host port jsonWSServerFromChan