ws-chans alternatives and similar packages
Based on the "network" category.
Alternatively, view ws-chans alternatives based on common mentions on social networks and blogs.
-
compendium-client
DISCONTINUED. Mu (μ) is a purely functional framework for building micro services. -
altsvc
DISCONTINUED. HTTP Alternative Services in Haskell [GET https://api.github.com/repos/ocheron/hs-altsvc: 404 - Not Found // See: https://docs.github.com/rest/repos/repos#get-a-repository]
SaaSHub - Software Alternatives and Reviews
Do you think we are missing an alternative of ws-chans or a related project?
README
ws-chans
Websockets represent a channel between a client and a server. ws-chans carries this concept deeper into your code by setting up an Control.Concurrent.Chan.Unagi.InChan and an Control.Concurrent.Chan.Unagi.OutChan as an interface to a websocket server. To send a message to the server you simply write a message to the InChan. To receive a message from the server you read from the OutChan.
The tests are probably the best place to look at some example usage but basically:
import Control.Monad (forM, forever)
import Data.Text (Text)
import Network.WebSockets.Chan.Unagi as Unagi
example :: IO [Text]
example = do
(ic, oc, cic) <- Unagi.newChans "localhost" 8080 "" :: IO (Unagi.InChan Text, Unagi.OutChan Text, Unagi.InChan Text)
Unagi.writeList2Chan ic msgs
res <- forM msgs (\_ -> Unagi.readChan oc)
Unagi.writeChan cic ("finished" :: Text)
return res
newChans returns a tuple of:
- an
InChanwhich you write messages to, these will be sent to the websocket server - an
OutChanwhich you read messages from, these are messages that have come from the websocket server - an
InChanfor closing the connection. This should have the same type as the firstInChan. When you write a message to thisInChanit will tell the server that you wish to close the connection. See the source code and Network.WebSockets.sendClose for more information on how this works.