1.1.4 • Published 4 years ago

bs-ws v1.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

bs-ws

Simple node websocket implementation for Reason

npm

GitHub issues

Installation

npm install --save bs-ws

or

npm i -S bs-ws

Then add bs-ws to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["bs-ws"]
}

Examples

Simple Example

let ws = Ws.WebSocket.make("wss://www.example.com");
Ws.WebSocket.(
ws
-> on(`message((data) => Js.log("Message: " ++ data)))
-> on(`close((code, reason) => Js.log("Closed: " ++ string_of_int(code) ++ reason)))
-> on(`open_(() => Js.log("Opened!")))
-> on(`error(error => Js.log("Error: " ++ Ws.ErrorEvent.message(error))))
);

Example with subprotocols

let ws = Ws.WebSocket.makeWithProtocols("wss://www.example.com", [| "soap" |]);
Ws.WebSocket.(
ws
-> on(`message((data) => Js.log("Message: " ++ data)))
-> on(`close((code, reason) => Js.log("Closed: " ++ string_of_int(code) ++ reason)))
-> on(`open_(() => Js.log("Opened!")))
-> on(`error(error => Js.log("Error: " ++ Ws.ErrorEvent.message(error))))
);

Send

let ws = Ws.WebSocket.make("wss://www.example.com");
Ws.WebSocket.(
ws
-> send("Hello World!")
);
1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago