fay-websockets-0.0.1.1: Websockets FFI library for Fay

Safe HaskellNone
LanguageHaskell2010

WebSockets

Synopsis

Documentation

data WebSocket Source #

WebSocket object to keep connection, handle events and sending data.

data WSEvent Source #

WebSocket event.

data WSState Source #

State of WebSocket

Constructors

Connecting 
Open 
Closing 
Closed 

getWsUrl :: Fay Text Source #

Get current url and replace http with ws.

onOpen :: WSEvent -> Fay () Source #

Wrapper over '.onopen' event.

onClose :: WebSocket -> Fay f -> Fay () Source #

Wrapper over '.onclose' event.

onError :: WebSocket -> Fay f -> Fay () Source #

Wrapper over '.onError' event.

eventData :: WSEvent -> Fay Text Source #

Get text data from event.

onMessage :: WSEvent -> Fay () Source #

Wrapper over '.onMessage'

websocket Source #

Arguments

:: Text

WebSocket endpoint URL;

-> (WSEvent -> Fay ())

when connection opened ;

-> (WSEvent -> Fay ())

when messages received;

-> (WSEvent -> Fay ())

when errors occured;

-> (WSEvent -> Fay ())

when connection closed.

-> Fay WebSocket 

Key function that by given URL initialize connection, starts to listen all events and ready to sending data.

sendWS :: WebSocket -> Text -> Fay () Source #

Send text data over WebSocket.

close :: WebSocket -> Fay () Source #

Close current connection.