Update WebSockets.hs

Add `send and  receive` `DataMessageE` so the whole WS API is mirrored
This commit is contained in:
Marcin Tolysz 2015-07-19 23:49:35 +01:00
parent 46fbb1a615
commit 1420f627e3

View File

@ -7,6 +7,7 @@ module Yesod.WebSockets
, webSockets
, receiveData
, receiveDataE
, sendDataMessageE
, sendPing
, sendPingE
, sendClose
@ -15,6 +16,7 @@ module Yesod.WebSockets
, sendTextDataE
, sendBinaryData
, sendBinaryDataE
, sendDataMessageE
-- * Conduit API
, sourceWS
, sinkWSText
@ -87,6 +89,12 @@ receiveData = ReaderT $ liftIO . WS.receiveData
receiveDataE :: (MonadIO m, WS.WebSocketsData a) => WebSocketsT m (Either SomeException a)
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.
--
-- Since 0.1.0
@ -125,6 +133,12 @@ sendPing = wrapWS WS.sendPing
sendPingE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())
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.
--
-- Since 0.2.2