packages feed

websockets-rpc 0.5.0 → 0.5.1

raw patch · 4 files changed

+51/−15 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Network.WebSockets.RPC: execWebSocketClientRPCTSimple :: (MonadBaseControl IO m) => WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m) -> m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) m)
+ Network.WebSockets.RPC: execWebSocketServerRPCTSimple :: (MonadBaseControl IO m) => WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m) -> m (WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) m)
+ Network.WebSockets.RPC: runWebSocketClientRPCTSimple :: (Monad m) => (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
+ Network.WebSockets.RPC: runWebSocketServerRPCTSimple :: (Monad m) => (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

Files

example/Main-Client.hs view
@@ -77,14 +77,11 @@       runWS :: WebSocketClientRPCT MyRepDSL MyComDSL IO a -> IO a       runWS = runWebSocketClientRPCT' env -      mkWS :: IO a -> WebSocketClientRPCT MyRepDSL MyComDSL IO a-      mkWS = lift--  client <- runWebSocketClientRPCT' env $ rpcClientSimple myClient+  client <- runWebSocketClientRPCT' env (rpcClientSimple myClient)    -- client <- ackableRPCClient id ("client" :: String) myClient   let myClient' :: ClientApp ()-      myClient' = runClientAppT runM $ toClientAppT' $ hoistWebSocketsApp runWS mkWS client+      myClient' = runClientAppT runM $ toClientAppT' $ runWebSocketClientRPCTSimple runWS client    threadDelay 1000000   runClientAppTBackingOff id "127.0.0.1" 8080 "" myClient'
example/Main.hs view
@@ -67,18 +67,12 @@  main :: IO () main = do-  (env :: Env MySubDSL MySupDSL IO) <- newEnv-   let runM = id -      runWS :: WebSocketServerRPCT MySubDSL MySupDSL IO a -> IO a-      runWS = runWebSocketServerRPCT' env--      mkWS :: IO a -> WebSocketServerRPCT MySubDSL MySupDSL IO a-      mkWS = lift+  server <- execWebSocketServerRPCTSimple $ rpcServerSimple myServer    -- server <- ackableRPCServer runM ("server" :: String) myServer   let myServer' :: ServerApp-      myServer' = runServerAppT runM $ toServerAppT $ hoistWebSocketsApp runWS mkWS $ rpcServerSimple myServer+      myServer' = runServerAppT runM $ toServerAppT server    runServer "127.0.0.1" 8080 myServer'
src/Network/WebSockets/RPC.hs view
@@ -15,6 +15,10 @@   , WebSocketRPCException (..)   , runClientAppTBackingOff   , rpcServerSimple, rpcClientSimple+  , runWebSocketClientRPCTSimple+  , execWebSocketClientRPCTSimple+  , runWebSocketServerRPCTSimple+  , execWebSocketServerRPCTSimple   ) where  import Network.WebSockets.RPC.Trans.Server ( WebSocketServerRPCT, execWebSocketServerRPCT@@ -24,12 +28,14 @@                                            , registerReplyComplete, runReply, runComplete, unregisterReplyComplete                                            , freshRPCID, runWebSocketClientRPCT', getClientEnv                                            )+import qualified Network.WebSockets.RPC.Trans.Server as Server+import qualified Network.WebSockets.RPC.Trans.Client as Client import Network.WebSockets.RPC.Types ( WebSocketRPCException (..), Subscribe (..), Supply (..), Reply (..), Complete (..)                                     , ClientToServer (Sub, Sup, Ping), ServerToClient (Rep, Com, Pong)                                     , RPCIdentified (..)                                     ) import Network.WebSockets (acceptRequest, receiveDataMessage, sendDataMessage, DataMessage (Text, Binary), ConnectionException, runClient)-import Network.WebSockets.Simple (WebSocketsApp (..))+import Network.WebSockets.Simple (WebSocketsApp (..), hoistWebSocketsApp) import Network.Wai.Trans (ServerAppT, ClientAppT, runClientAppT) import Data.Aeson (ToJSON, FromJSON, decode, encode) import Data.IORef (newIORef, readIORef, writeIORef)@@ -319,3 +325,42 @@       loop = attemptRun app' `catch` handleConnError    loop++runWebSocketClientRPCTSimple  :: ( Monad m+                                 )+                              => (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+++execWebSocketClientRPCTSimple  :: ( MonadBaseControl IO m+                                  )+                                => WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m)+                                -> m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) m)+execWebSocketClientRPCTSimple x = do+  env <- liftBaseWith $ \_ -> Client.newEnv++  let runWS = runWebSocketClientRPCT' env++  pure $ runWebSocketClientRPCTSimple runWS x+++runWebSocketServerRPCTSimple :: ( Monad m+                                )+                             => (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+++execWebSocketServerRPCTSimple  :: ( MonadBaseControl IO m+                                  )+                               =>    WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m)+                               -> m (WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) m)+execWebSocketServerRPCTSimple x = do+  env <- liftBaseWith $ \_ -> Server.newEnv++  let runWS = runWebSocketServerRPCT' env++  pure $ runWebSocketServerRPCTSimple runWS x
websockets-rpc.cabal view
@@ -1,5 +1,5 @@ Name:                   websockets-rpc-Version:                0.5.0+Version:                0.5.1 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                BSD3