Module

WebSocket.Ws

Package
purescript-ws
Repository
FruitieX/purescript-ws

#WebSocketServer Source

data WebSocketServer :: Type

The type of a WebSocket server object

#WebSocketConnection Source

#WS Source

data WS :: Effect

The effect associated with using the WebSocket module

#WebSocketServerOptions Source

type WebSocketServerOptions = (backlog :: Int, host :: String)

#Port Source

newtype Port

The port to listen on if calling createWebSocketServerWithPort

Constructors

#CloseCode Source

newtype CloseCode

Constructors

#CloseReason Source

newtype CloseReason

Constructors

#createWebSocketServer_ Source

createWebSocketServer_ :: forall options e. EffFn2 (ws :: WS | e) options (EffFn1 (ws :: WS | e) Unit Unit) WebSocketServer

#createWebSocketServerWithPort Source

createWebSocketServerWithPort :: forall trash options' options e. Union options options' WebSocketServerOptions => RowLacks "port" options => RowCons "port" Port options trash => Port -> Record options -> (Unit -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) WebSocketServer

Creates a WebSocket.Server and internally a HTTP server which binds to a given port

The supplied callback is called when the created HTTP server starts listening.

#createWebSocketServerWithServer Source

createWebSocketServerWithServer :: forall trash options' options e. Union options options' WebSocketServerOptions => RowLacks "server" options => RowCons "server" Server options trash => Server -> Record options -> Eff (ws :: WS | e) WebSocketServer

Creates a WebSocket.Server from a pre-existing Node.Server

#onConnection_ Source

#onConnection Source

onConnection :: forall e. WebSocketServer -> (WebSocketConnection -> Request -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) Unit

Attaches a connection event handler to a WebSocketServer

#onServerError_ Source

onServerError_ :: forall e. EffFn2 (ws :: WS | e) WebSocketServer (EffFn1 (ws :: WS | e) Error Unit) Unit

#onServerError Source

onServerError :: forall e. WebSocketServer -> (Error -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) Unit

Attaches an error event handler to a WebSocketServer

#onMessage_ Source

onMessage_ :: forall e. EffFn2 (ws :: WS | e) WebSocketConnection (EffFn1 (ws :: WS | e) WebSocketMessage Unit) Unit

#onMessage Source

onMessage :: forall e. WebSocketConnection -> (WebSocketMessage -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) Unit

Attaches a message event handler to a WebSocketConnection

#onClose_ Source

onClose_ :: forall e. EffFn2 (ws :: WS | e) WebSocketConnection (EffFn2 (ws :: WS | e) CloseCode CloseReason Unit) Unit

#onClose Source

onClose :: forall e. WebSocketConnection -> (CloseCode -> CloseReason -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) Unit

Attaches a close event handler to a WebSocketConnection

#onError_ Source

onError_ :: forall e. EffFn2 (ws :: WS | e) WebSocketConnection (EffFn1 (ws :: WS | e) Error Unit) Unit

#onError Source

onError :: forall e. WebSocketConnection -> (Error -> Eff (ws :: WS | e) Unit) -> Eff (ws :: WS | e) Unit

Attaches an error event handler to a WebSocketConnection

#sendMessage Source

sendMessage :: forall e. WebSocketConnection -> WebSocketMessage -> Eff (ws :: WS | e) Unit

Send a message over a WebSocketConnection

#close Source

close :: forall e. WebSocketConnection -> Eff (ws :: WS | e) Unit

Initiate a closing handshake

#close' Source

close' :: forall e. WebSocketConnection -> CloseCode -> CloseReason -> Eff (ws :: WS | e) Unit

Initiate a closing handshake with given code and reason

Modules
WebSocket.Ws