websockets-0.13.0.0: A sensible and clean way to write WebSocket-capable servers in Haskell.

Safe Haskell | None
Language | Haskell2010

Network.WebSockets.Client

Contents

- Low level functionality

Description

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.

runClient Source #

Arguments

:: String | Host
-> Int | Port
-> String | Path
-> ClientApp a | Client application
-> IO a |

runClientWith Source #

Arguments

:: String | Host
-> Int | Port
-> String | Path
-> ConnectionOptions | Options
-> Headers | Custom headers to send
-> ClientApp a | Client application
-> IO a |

runClientWithSocket Source #

Arguments

:: Socket | Socket
-> String | Host
-> String | Path
-> ConnectionOptions | Options
-> Headers | Custom headers to send
-> ClientApp a | Client application
-> IO a |

runClientWithStream Source #

Arguments

:: Stream | Stream
-> String | Host
-> String | Path
-> ConnectionOptions | Connection options
-> Headers | Custom headers to send
-> ClientApp a | Client application
-> IO a |

newClientConnection Source #

Arguments

:: Stream | Stream that will be used by the new `Connection`.
-> 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 #

data Protocol Source #

Constructors

Hybi13 |

#### Instances

Instances details

Show Protocol Source # |
Instance details Defined in Network.WebSockets.Protocol Methods showsPrec :: Int -> Protocol -> ShowS Source # show :: Protocol -> String Source # showList :: [Protocol] -> ShowS Source #

defaultProtocol :: Protocol 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.