| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Wuss
Description
Wuss is a library that lets you easily create secure WebSocket clients over the WSS protocol. It is a small addition to the websockets package and is adapted from existing solutions by @jaspervdj, @mpickering, and @elfenlaid.
Example
import Wuss
import Control.Concurrent (forkIO)
import Control.Monad (forever, unless, void)
import Data.Text (Text, pack)
import Network.WebSockets (ClientApp, receiveData, sendClose, sendTextData)
main :: IO ()
main = runSecureClient "echo.websocket.org" 443 "/" ws
ws :: ClientApp ()
ws connection = do
putStrLn "Connected!"
void . forkIO . forever $ do
message <- receiveData connection
print (message :: Text)
let loop = do
line <- getLine
unless (null line) $ do
sendTextData connection (pack line)
loop
loop
sendClose connection (pack "Bye!")- runSecureClient :: HostName -> PortNumber -> String -> ClientApp a -> IO a
- runSecureClientWith :: HostName -> PortNumber -> String -> ConnectionOptions -> Headers -> ClientApp a -> IO a
Documentation
Arguments
| :: HostName | Host |
| -> PortNumber | Port |
| -> String | Path |
| -> ClientApp a | Application |
| -> IO a |
A secure replacement for runClient.
>>>let app _connection = return ()>>>runSecureClient "echo.websocket.org" 443 "/" app
Arguments
| :: HostName | Host |
| -> PortNumber | Port |
| -> String | Path |
| -> ConnectionOptions | Options |
| -> Headers | Headers |
| -> ClientApp a | Application |
| -> IO a |
A secure replacement for runClientWith.
>>>let options = defaultConnectionOptions>>>let headers = []>>>let app _connection = return ()>>>runSecureClientWith "echo.websocket.org" 443 "/" options headers app