packages feed

websockets-rpc 0.5.1 → 0.6.0

raw patch · 4 files changed

+25/−16 lines, 4 filesdep ~websockets-simplePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: websockets-simple

API changes (from Hackage documentation)

- Network.WebSockets.RPC: rpcClientSimple :: forall sub sup rep com m. (MonadIO m) => RPCClient sub sup rep com m -> WebSocketClientRPCT rep com m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m))
+ Network.WebSockets.RPC: rpcClientSimple :: forall sub sup rep com m. (MonadIO m) => (Maybe (Word16, ByteString) -> m ()) -> RPCClient sub sup rep com m -> WebSocketClientRPCT rep com m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m))
- Network.WebSockets.RPC: rpcServerSimple :: forall sub sup rep com m. (MonadBaseControl IO m, MonadIO m) => RPCServer sub sup rep com m -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m)
+ Network.WebSockets.RPC: rpcServerSimple :: forall sub sup rep com m. (MonadBaseControl IO m, MonadIO m) => (Maybe (Word16, ByteString) -> m ()) -> RPCServer sub sup rep com m -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m)

Files

example/Main-Client.hs view
@@ -6,8 +6,9 @@  module Main where +import Network.Wai.Trans (runClientAppT) import Network.WebSockets (runServer, runClient, ServerApp, ClientApp)-import Network.WebSockets.Simple (toClientAppT', hoistWebSocketsApp)+import Network.WebSockets.Simple (toClientAppT', hoistWebSocketsApp, expBackoffStrategy) import Network.WebSockets.RPC import Network.WebSockets.RPC.ACKable (ackableRPCClient) import Network.WebSockets.RPC.Trans.Client (newEnv, Env, runWebSocketClientRPCT')@@ -77,11 +78,12 @@       runWS :: WebSocketClientRPCT MyRepDSL MyComDSL IO a -> IO a       runWS = runWebSocketClientRPCT' env -  client <- runWebSocketClientRPCT' env (rpcClientSimple myClient)+  client <- runWebSocketClientRPCT' env (rpcClientSimple (\_ -> putStrLn "connection closed"+                                                         ) myClient)    -- client <- ackableRPCClient id ("client" :: String) myClient   let myClient' :: ClientApp ()       myClient' = runClientAppT runM $ toClientAppT' $ runWebSocketClientRPCTSimple runWS client    threadDelay 1000000-  runClientAppTBackingOff id "127.0.0.1" 8080 "" myClient'+  expBackoffStrategy $ runClient "127.0.0.1" 8080 "" $ runClientAppT id myClient'
example/Main.hs view
@@ -69,7 +69,8 @@ main = do   let runM = id -  server <- execWebSocketServerRPCTSimple $ rpcServerSimple myServer+  server <- execWebSocketServerRPCTSimple $ rpcServerSimple ( \_ -> putStrLn "connection closed"+                                                            ) myServer    -- server <- ackableRPCServer runM ("server" :: String) myServer   let myServer' :: ServerApp
src/Network/WebSockets/RPC.hs view
@@ -35,10 +35,12 @@                                     , RPCIdentified (..)                                     ) import Network.WebSockets (acceptRequest, receiveDataMessage, sendDataMessage, DataMessage (Text, Binary), ConnectionException, runClient)-import Network.WebSockets.Simple (WebSocketsApp (..), hoistWebSocketsApp)+import Network.WebSockets.Simple (WebSocketsApp (..), hoistWebSocketsApp, WebSocketsAppParams (..)) import Network.Wai.Trans (ServerAppT, ClientAppT, runClientAppT) import Data.Aeson (ToJSON, FromJSON, decode, encode) import Data.IORef (newIORef, readIORef, writeIORef)+import Data.Word (Word16)+import Data.ByteString.Lazy (ByteString)  import Control.Monad (forever, void) import Control.Monad.IO.Class (liftIO, MonadIO)@@ -129,11 +131,12 @@                  . ( MonadBaseControl IO m                    , MonadIO m                    )-                => RPCServer sub sup rep com m+                => (Maybe (Word16, ByteString) -> m ()) -- ^ see 'Network.WebSockets.Simple.onClose'+                -> RPCServer sub sup rep com m                 -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m)-rpcServerSimple f = WebSocketsApp+rpcServerSimple onClose f = WebSocketsApp   { onOpen = \send -> pure ()-  , onReceive = \send eSubSup -> do+  , onReceive = \WebSocketsAppParams{send} eSubSup -> do       env <- getServerEnv        let runSub :: Subscribe sub -> WebSocketServerRPCT sub sup m ()@@ -165,6 +168,7 @@       case eSubSup of         Left sub -> runSub sub         Right sup -> runSup sup+  , onClose = lift . onClose   }  @@ -256,12 +260,13 @@ rpcClientSimple :: forall sub sup rep com m                  . ( MonadIO m                    )-                => RPCClient sub sup rep com m+                => (Maybe (Word16, ByteString) -> m ()) -- ^ see 'Network.WebSockets.Simple.onClose'+                -> RPCClient sub sup rep com m                 -> WebSocketClientRPCT rep com m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m))-rpcClientSimple RPCClient{subscription,onSubscribe,onReply,onComplete} = do+rpcClientSimple onClose RPCClient{subscription,onSubscribe,onReply,onComplete} = do   _ident <- freshRPCID   pure WebSocketsApp-    { onOpen = \send -> do+    { onOpen = \WebSocketsAppParams{send} -> do         send $ Left $ Subscribe RPCIdentified{_ident, _params = subscription}          env <- getClientEnv@@ -276,7 +281,7 @@          registerReplyComplete _ident (onReply RPCClientParams{supply,cancel}) onComplete -    , onReceive = \send eRepCom -> do+    , onReceive = \WebSocketsAppParams{send} eRepCom -> do         let runRep :: Reply rep -> WebSocketClientRPCT rep com m ()             runRep (Reply RPCIdentified{_ident = _ident',_params})               | _ident' == _ident = runReply _ident _params@@ -292,6 +297,7 @@         case eRepCom of           Left rep -> runRep rep           Right com -> runCom com+    , onClose = lift . onClose     }  @@ -331,7 +337,7 @@                               => (forall a. WebSocketClientRPCT rep com m a -> m a)                               -> WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m)                               -> WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) m-runWebSocketClientRPCTSimple runWS x = hoistWebSocketsApp runWS lift x+runWebSocketClientRPCTSimple runWS = hoistWebSocketsApp runWS lift   execWebSocketClientRPCTSimple  :: ( MonadBaseControl IO m@@ -351,7 +357,7 @@                              => (forall a. WebSocketServerRPCT sub sup m a -> m a)                              -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m)                              -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) m-runWebSocketServerRPCTSimple runWS x = hoistWebSocketsApp runWS lift x+runWebSocketServerRPCTSimple runWS = hoistWebSocketsApp runWS lift   execWebSocketServerRPCTSimple  :: ( MonadBaseControl IO m
websockets-rpc.cabal view
@@ -1,5 +1,5 @@ Name:                   websockets-rpc-Version:                0.5.1+Version:                0.6.0 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                BSD3@@ -44,7 +44,7 @@                       , uuid                       , wai-transformers                       , websockets >= 0.11-                      , websockets-simple >= 0.0.2.2+                      , websockets-simple >= 0.0.5  Test-suite test   Type:                 exitcode-stdio-1.0