Skip to content

Commit

Permalink
Update readme with WS syntax and HTTP client uses
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacgr committed Jul 12, 2019
1 parent ecbd177 commit a444d2f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The default host and port for the server is `127.0.0.1:8100`. Based on the node

The default host and port for the TCP client is `127.0.0.1:8100`. Based on the node `net.Socket()` module.

The default host and port for the HTTP client is `http://127.0.0.1:80/`. Based on the node `http.ClientRequest` module.
The default request URL for the HTTP client is `http://127.0.0.1:8100/`. Based on the node `http.ClientRequest` module.

The default url for the WS client is `ws://127.0.0.1:8100`. Based on the `WebSocket` module from JavaScript.

Expand All @@ -133,6 +133,7 @@ The default options will be used when instantiating the client or the server. Ov
```js
const Jaysonic = require("jaysonic");

// server with overrides
const server = new Jaysonic.server.tcp({
host: "127.0.0.1",
port: 8100,
Expand All @@ -146,6 +147,7 @@ const server = new Jaysonic.server.tcp({
```js
const Jaysonic = require("jaysonic");

// client with overrides
const client = new Jaysonic.client.http({
method: "POST",
headers: {
Expand All @@ -161,8 +163,10 @@ const client = new Jaysonic.client.http({

```js
const Jaysonic = require("jaysonic");
const socket = require("jaysonic/lib/client-ws");

const ws = new Jaysonic.client.ws({
// client and server with overrides
const ws = new socket.wsclient({
url: "ws://127.0.0.1:8100"
});

Expand All @@ -178,7 +182,7 @@ const wss = new Jaysonic.server.ws({
```js
const Jaysonic = require("jaysonic");

const server = new Jaysonic.server.tcp({ host: "127.0.0.1", port: 8100 });
const server = new Jaysonic.server.tcp();

server
.listen()
Expand Down Expand Up @@ -236,7 +240,7 @@ server.clientDisconnected(({ host, port }) => {

```js
const Jaysonic = require("jaysonic");
const client = new Jaysonic.client.tcp({ host: "127.0.0.1", port: 8100 });
const client = new Jaysonic.client.tcp();

client
.connect()
Expand All @@ -248,6 +252,8 @@ client
});
```

**Note that the HTTP client does not have a connect() method and can just begin making requests to the server.**

##### Listening for server disconnect

The `serverDisconnected` method fires a callback when the server is disconnected.
Expand Down

0 comments on commit a444d2f

Please sign in to comment.