Skip to content

Commit

Permalink
doc: update examples according to the new API
Browse files Browse the repository at this point in the history
PR-URL: #209
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Dmytro Nechai <nechaido@gmail.com>
  • Loading branch information
lundibundi committed Jun 21, 2017
1 parent 34cd6ee commit a09dfe8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const app = new jstp.Application('testApp', {
// WebSocket and Unix domain sockets. One might notice that an array of
// applications is passed the `createServer()`. That's because it can serve
// any number of applications.
const server = jstp.tcp.createServer(3000, [app]);
server.listen(() => {
const server = jstp.net.createServer([app]);
server.listen(3000, () => {
console.log('TCP server listening on port 3000 🚀');
});
```
Expand All @@ -100,15 +100,18 @@ Client:

const jstp = require('metarhia-jstp');

// Create a TCP client. Clients can have applications too for full-duplex RPC,
// but we don't need that in this example.
const client = jstp.tcp.createClient({ host: 'localhost', port: 3000 });

// Connect to the `testApp` application. Username and password are both `null`
// Create a TCP connection to server and connect to the `testApp` application.
// Clients can have applications too for full-duplex RPC,
// but we don't need that in this example. Client is `null` in this example,
// this implies that username and password are both `null`
// here — that is, the protocol-level authentication is not leveraged in this
// example. The next argument is an array of interfaces to inspect and build
// remote proxy objects for.
client.connectAndInspect('testApp', null, null, ['someService'], handleConnect);
// remote proxy objects for. Remaining arguments are for
// net.connect (host and port) and last argument is a callback
// to be called on successful connection or error.
const client = jstp.net.connectAndInspect(
'testApp', null, ['someService'], 3000, 'localhost', handleConnect

This comment has been minimized.

Copy link
@aqrln

aqrln Jun 22, 2017

Member

Indentation is inconsistent here.

And can you please not reviewed-by tag me on commits I did not review and have never seen? Thanks.

This comment has been minimized.

Copy link
@lundibundi

lundibundi Jun 22, 2017

Author Member

Yeah, missed that. Will add a PR to fix that.
Sorry for that mistake, already fixed on master.

);

function handleConnect(error, connection, app) {
if (error) {
Expand Down
17 changes: 10 additions & 7 deletions examples/readme-example/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

const jstp = require('../..');

// Create a TCP client. Clients can have applications too for full-duplex RPC,
// but we don't need that in this example.
const client = jstp.tcp.createClient({ host: 'localhost', port: 3000 });

// Connect to the `testApp` application. Username and password are both `null`
// Create a TCP connection to server and connect to the `testApp` application.
// Clients can have applications too for full-duplex RPC,
// but we don't need that in this example. Client is `null` in this example,
// this implies that username and password are both `null`
// here — that is, the protocol-level authentication is not leveraged in this
// example. The next argument is an array of interfaces to inspect and build
// remote proxy objects for.
client.connectAndInspect('testApp', null, null, ['someService'], handleConnect);
// remote proxy objects for. Remaining arguments are for
// net.connect (host and port) and last argument is a callback
// to be called on successful connection or error.
jstp.net.connectAndInspect(
'testApp', null, ['someService'], 3000, 'localhost', handleConnect
);

function handleConnect(error, connection, app) {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/readme-example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const app = new jstp.Application('testApp', {
// WebSocket and Unix domain sockets. One might notice that an array of
// applications is passed the `createServer()`. That's because it can serve
// any number of applications.
const server = jstp.tcp.createServer(3000, [app]);
server.listen(() => {
const server = jstp.net.createServer([app]);
server.listen(3000, () => {
console.log('TCP server listening on port 3000 🚀');
});

0 comments on commit a09dfe8

Please sign in to comment.