Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This part of the library provides you with utilities to create WebSockets clients (in addition to servers).
Synopsis
- type ClientApp a = Connection -> IO a
- runClient :: String -> Int -> String -> ClientApp a -> IO a
- runClientWith :: String -> Int -> String -> ConnectionOptions -> Headers -> ClientApp a -> IO a
- runClientWithSocket :: Socket -> String -> String -> ConnectionOptions -> Headers -> ClientApp a -> IO a
- runClientWithStream :: Stream -> String -> String -> ConnectionOptions -> Headers -> ClientApp a -> IO a
- newClientConnection :: Stream -> String -> String -> ConnectionOptions -> Headers -> IO Connection
- createRequest :: Protocol -> ByteString -> ByteString -> Bool -> Headers -> IO RequestHead
- data Protocol = Hybi13
- defaultProtocol :: Protocol
- checkServerResponse :: Stream -> RequestHead -> IO ()
- streamToClientConnection :: Stream -> ConnectionOptions -> IO Connection
Documentation
type ClientApp a = Connection -> IO a Source #
A client application interacting with a single server. Once this IO
action finished, the underlying socket is closed automatically.
:: Stream | Stream that will be used by the new |
-> String | Host |
-> String | Path |
-> ConnectionOptions | Connection options |
-> Headers | Custom headers to send |
-> IO Connection |
Build a new Connection
from the client's point of view.
WARNING: Be sure to call 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.
Low level functionality
createRequest :: Protocol -> ByteString -> ByteString -> Bool -> Headers -> IO RequestHead Source #
checkServerResponse :: Stream -> RequestHead -> IO () Source #
Check the response from the server.
Throws OtherHandshakeException
on failure
streamToClientConnection :: Stream -> ConnectionOptions -> IO Connection Source #
Build a Connection
from a pre-established stream with already finished
handshake.
NB: this will not perform any handshaking.