Module
WebSocket
- Package
- purescript-websocket-simple
- Repository
- zudov/purescript-websocket-simple
This module defines a simple low-level interface to the websockets API.
#newWebSocket Source
newWebSocket :: forall eff. URL -> Array Protocol -> Eff (err :: EXCEPTION, ws :: WEBSOCKET | eff) Connection
Initiate a websocket connection.
#Connection Source
newtype Connection
binaryType
-- The type of binary data being transmitted by the connection.bufferedAmount
-- The number of bytes of data that have been queued using calls tosend
but not yet transmitted to the network. This value does not reset to zero when the connection is closed; if you keep callingsend
, this will continue to climb.onclose
-- An event listener to be called when theConnection
'sreadyState
changes toClosed
.onerror
-- An event listener to be called when an error occurs.onmessage
-- An event listener to be called when a message is received from the server.onopen
-- An event listener to be called when theConnection
's readyState changes toOpen
; this indicates that the connection is ready to send and receive data.protocol
-- A string indicating the name of the sub-protocol the server selected.readyState
-- The current state of the connection.url
-- The URL as resolved by during construction. This is always an absolute URL.close
-- Closes the connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing. IfCode
isn't specified a default value of 1000 (indicating a normal "transaction complete" closure) is assumedsend
-- Transmits data to the server.socket
-- Reference to closured WebSocket object.
Constructors
Connection { binaryType :: forall eff. Var (ws :: WEBSOCKET | eff) BinaryType, bufferedAmount :: forall eff. GettableVar (ws :: WEBSOCKET | eff) BufferedAmount, close :: forall eff. Eff (err :: EXCEPTION, ws :: WEBSOCKET | eff) Unit, close' :: forall eff. Code -> Maybe Reason -> Eff (err :: EXCEPTION, ws :: WEBSOCKET | eff) Unit, onclose :: forall handlerEff eff. SettableVar (ws :: WEBSOCKET | eff) (CloseEvent -> Eff handlerEff Unit), onerror :: forall handlerEff eff. SettableVar (ws :: WEBSOCKET | eff) (Event -> Eff handlerEff Unit), onmessage :: forall handlerEff eff. SettableVar (ws :: WEBSOCKET | eff) (MessageEvent -> Eff handlerEff Unit), onopen :: forall handlerEff eff. SettableVar (ws :: WEBSOCKET | eff) (Event -> Eff handlerEff Unit), protocol :: forall eff. Var (ws :: WEBSOCKET | eff) Protocol, readyState :: forall eff. GettableVar (ws :: WEBSOCKET | eff) ReadyState, send :: forall eff. Message -> Eff (err :: EXCEPTION, ws :: WEBSOCKET | eff) Unit, socket :: forall eff. GettableVar (ws :: WEBSOCKET | eff) WebSocket, url :: forall eff. GettableVar (ws :: WEBSOCKET | eff) URL }
#BinaryType Source
#BufferedAmount Source
newtype BufferedAmount
The number of bytes of data that have been buffered (queued but not yet transmitted)
Instances
#runProtocol Source
runProtocol :: Protocol -> String
#ReadyState Source
#runMessage Source
runMessage :: Message -> String
- Modules
- WebSocket