websockets 0.12.4.1 → 0.12.5.0
raw patch · 4 files changed
+30/−3 lines, 4 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG +3/−0
- src/Network/WebSockets.hs +1/−0
- src/Network/WebSockets/Client.hs +25/−2
- websockets.cabal +1/−1
CHANGELOG view
@@ -1,5 +1,8 @@ # CHANGELOG +- 0.12.5.0 (2018-06-01)+ * Add `newClientConnection` (by Renzo Carbonara)+ - 0.12.4.1 (2018-05-11) * Bump `network` dependency to 2.7
src/Network/WebSockets.hs view
@@ -77,6 +77,7 @@ , runClientWith , runClientWithSocket , runClientWithStream+ , newClientConnection -- * Utilities , forkPingThread
src/Network/WebSockets/Client.hs view
@@ -7,6 +7,7 @@ , runClientWith , runClientWithSocket , runClientWithStream+ , newClientConnection ) where @@ -77,6 +78,7 @@ --------------------------------------------------------------------------------+ runClientWithStream :: Stream -- ^ Stream@@ -92,6 +94,27 @@ -- ^ Client application -> IO a runClientWithStream stream host path opts customHeaders app = do+ newClientConnection stream host path opts customHeaders >>= app++-- | Build a new 'Connection' from the client's point of view.+--+-- /WARNING/: Be sure to call 'Stream.close' on the given 'Stream' after you are+-- done using the 'Connection' in order to properly close the communication+-- channel. 'runClientWithStream' handles this for you, prefer to use it when+-- possible.+newClientConnection+ :: Stream+ -- ^ Stream that will be used by the new 'Connection'.+ -> String+ -- ^ Host+ -> String+ -- ^ Path+ -> ConnectionOptions+ -- ^ Connection options+ -> Headers+ -- ^ Custom headers to send+ -> IO Connection+newClientConnection stream host path opts customHeaders = do -- Create the request and send it request <- createRequest protocol bHost bPath False customHeaders Stream.write stream (Builder.toLazyByteString $ encodeRequestHead request)@@ -99,7 +122,7 @@ response <- case mbResponse of Just response -> return response Nothing -> throwIO $ OtherHandshakeException $- "Network.WebSockets.Client.runClientWithStream: no handshake " +++ "Network.WebSockets.Client.newClientConnection: no handshake " ++ "response from server" void $ either throwIO return $ finishResponse protocol request response parse <- decodeMessages protocol@@ -108,7 +131,7 @@ write <- encodeMessages protocol ClientConnection stream sentRef <- newIORef False - app Connection+ pure $ Connection { connectionOptions = opts , connectionType = ClientConnection , connectionProtocol = protocol
websockets.cabal view
@@ -1,5 +1,5 @@ Name: websockets-Version: 0.12.4.1+Version: 0.12.5.0 Synopsis: A sensible and clean way to write WebSocket-capable servers in Haskell.