Merge pull request #1035 from tolysz/patch-2

Update WebSockets.hs
This commit is contained in:
Michael Snoyman 2015-07-19 15:53:32 -07:00
commit 2ebf14aaba

View File

@ -7,6 +7,7 @@ module Yesod.WebSockets
, webSockets , webSockets
, receiveData , receiveData
, receiveDataE , receiveDataE
, sendDataMessageE
, sendPing , sendPing
, sendPingE , sendPingE
, sendClose , sendClose
@ -15,6 +16,7 @@ module Yesod.WebSockets
, sendTextDataE , sendTextDataE
, sendBinaryData , sendBinaryData
, sendBinaryDataE , sendBinaryDataE
, sendDataMessageE
-- * Conduit API -- * Conduit API
, sourceWS , sourceWS
, sinkWSText , sinkWSText
@ -87,6 +89,12 @@ receiveData = ReaderT $ liftIO . WS.receiveData
receiveDataE :: (MonadIO m, WS.WebSocketsData a) => WebSocketsT m (Either SomeException a) receiveDataE :: (MonadIO m, WS.WebSocketsData a) => WebSocketsT m (Either SomeException a)
receiveDataE = ReaderT $ liftIO . tryAny . WS.receiveData receiveDataE = ReaderT $ liftIO . tryAny . WS.receiveData
-- | Receive an application message.
-- Capture SomeException as the result or operation
-- Since 0.2.2
receiveDataMessageE :: (MonadIO m) => WebSocketsT m (Either SomeException WS.DataMessage)
receiveDataMessageE = ReaderT $ liftIO . tryAny . WS.receiveDataMessage
-- | Send a textual message to the client. -- | Send a textual message to the client.
-- --
-- Since 0.1.0 -- Since 0.1.0
@ -125,6 +133,12 @@ sendPing = wrapWS WS.sendPing
sendPingE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ()) sendPingE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())
sendPingE = wrapWSE WS.sendPing sendPingE = wrapWSE WS.sendPing
-- | Send a DataMessage to the client.
-- Capture SomeException as the result of operation
-- Since 0.2.2
sendDataMessageE :: (MonadIO m) => WS.DataMessage -> WebSocketsT m (Either SomeException ())
sendDataMessageE x = ReaderT $ liftIO . tryAny . (`WS.sendDataMessage` x)
-- | Send a close request to the client. -- | Send a close request to the client.
-- --
-- Since 0.2.2 -- Since 0.2.2