diff --git a/yesod-websockets/Yesod/WebSockets.hs b/yesod-websockets/Yesod/WebSockets.hs index 75f795f3..57778faa 100644 --- a/yesod-websockets/Yesod/WebSockets.hs +++ b/yesod-websockets/Yesod/WebSockets.hs @@ -6,8 +6,15 @@ module Yesod.WebSockets WebSocketsT , webSockets , receiveData + , receiveDataX + , sendPing + , sendPingX + , sendClose + , sendCloseX , sendTextData + , sendTextDataX , sendBinaryData + , sendBinaryDataX -- * Conduit API , sourceWS , sinkWSText @@ -92,6 +99,13 @@ sendTextDataX ex x = ReaderT $ \c -> liftIO $ (flip WS.sendTextData x $ c) `E.ca sendBinaryData :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m () sendBinaryData x = ReaderT $ liftIO . flip WS.sendBinaryData x +-- | Send a binary message to the client. +-- Execute IO () action on WebSocket Exception +-- Since 0.1.1.3 +sendBinaryDataX :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m () +sendBinaryDataX ex x = ReaderT $ \c -> liftIO $ (flip WS.sendBinaryData x $ c) `E.catch` (\(_ :: E.SomeException) -> ex) + + -- | Send a ping message to the client. -- -- Since 0.1.1.3