packages feed

apiary-websockets 0.7.0.0 → 0.8.0.0

raw patch · 2 files changed

+31/−17 lines, 2 filesdep ~apiaryPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: apiary

API changes (from Hackage documentation)

+ Web.Apiary.WebSockets: webSockets :: (Monad n, Functor n) => Fn xs ServerApp -> ApiaryT xs n m ()
+ Web.Apiary.WebSockets: webSockets' :: (Monad n, Functor n) => ConnectionOptions -> Fn xs ServerApp -> ApiaryT xs n m ()
- Web.Apiary.WebSockets: actionWithWebSockets :: Fn c ServerApp -> Fn c (Action ()) -> Apiary c ()
+ Web.Apiary.WebSockets: actionWithWebSockets :: (Functor n, Monad n) => Fn c ServerApp -> Fn c (ActionT n ()) -> ApiaryT c n m ()
- Web.Apiary.WebSockets: actionWithWebSockets' :: ConnectionOptions -> Fn xs ServerApp -> Fn xs (Action ()) -> Apiary xs ()
+ Web.Apiary.WebSockets: actionWithWebSockets' :: (Monad n, Functor n) => ConnectionOptions -> Fn xs ServerApp -> Fn xs (ActionT n ()) -> ApiaryT xs n m ()

Files

apiary-websockets.cabal view
@@ -1,5 +1,5 @@ name:                apiary-websockets-version:             0.7.0.0+version:             0.8.0.0 synopsis:            websockets supper for apiary web framework. description:   example: <https://github.com/philopon/apiary/blob/master/examples/websockets.hs>@@ -20,7 +20,7 @@   exposed-modules:     Web.Apiary.WebSockets   other-modules:          build-depends:       base               >=4.6   && <4.8-                     , apiary             >=0.7   && <0.8+                     , apiary             >=0.8   && <0.9                      , wai-websockets     >=2.1   && <2.2                      , websockets         >=0.8   && <0.9 
src/Web/Apiary/WebSockets.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoMonomorphismRestriction #-} module Web.Apiary.WebSockets (-      actionWithWebSockets +    webSockets, webSockets'+    , actionWithWebSockets      , actionWithWebSockets'     -- * Reexport     -- | PendingConnection,@@ -24,20 +25,33 @@     , sendTextData, sendBinaryData, sendClose, sendPing     ) -actionWithWebSockets' :: WS.ConnectionOptions +wsToApp :: Monad m => WS.ConnectionOptions +        -> Fn xs WS.ServerApp -> SList xs -> ActionT m ()+wsToApp conn srv args = getRequest >>= \req ->+    case WS.websocketsApp conn (apply srv args) req of+        Nothing -> return ()+        Just r  -> stopWith r++-- | websocket only action. since 0.8.0.0.+webSockets' :: (Monad n, Functor n) => WS.ConnectionOptions+            -> Fn xs WS.ServerApp -> ApiaryT xs n m ()+webSockets' conn srv = action' $ wsToApp conn srv++-- | websocket only action. since 0.8.0.0.+webSockets :: (Monad n, Functor n)+           => Fn xs WS.ServerApp -> ApiaryT xs n m ()+webSockets = webSockets' WS.defaultConnectionOptions++actionWithWebSockets' :: (Monad n, Functor n)+                      => WS.ConnectionOptions                        -> Fn xs WS.ServerApp-                      -> Fn xs (Action ())-                      -> Apiary xs ()-actionWithWebSockets' conn srv m = do-    actionWithPreAction pa m-  where-    pa args = do-        req <- getRequest-        case WS.websocketsApp conn (apply srv args) req of-            Nothing   -> return ()-            Just resp -> stopWith resp+                      -> Fn xs (ActionT n ())+                      -> ApiaryT xs n m ()+actionWithWebSockets' conn srv m =+    action' $ \a -> wsToApp conn srv a >> apply m a -actionWithWebSockets :: Fn c WS.ServerApp-                     -> Fn c (Action ())-                     -> Apiary c ()+actionWithWebSockets :: (Functor n, Monad n)+                     => Fn c WS.ServerApp+                     -> Fn c (ActionT n ())+                     -> ApiaryT c n m () actionWithWebSockets = actionWithWebSockets' WS.defaultConnectionOptions