Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial version of internal messaging fix #69

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ tmp/

# VS code local history
.history/
*.DS_Store

tsbuild/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* [Examples](#examples)
* [Basic Examples](#basicExamples)
* [Basic Examples](#basicExamples)
* [Advanced] (#advanced)
* [Advanced](#advanced)
* [Basic Examples](#basicExamples)
* [Basic Examples](#basicExamples)
* [Contributing](#contributing)
Expand Down
29 changes: 29 additions & 0 deletions examples/routingExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Node } from '../src'

// znode3
// /\
// / \
// / \
// znode1 znode2

(async function () {
let znode3 = new Node({bind: 'tcp://127.0.0.1:3000'})
let znode1 = new Node()
let znode2 = new Node()

await znode3.bind()
await znode1.connect({ address: znode3.getAddress() })
await znode2.connect({ address: znode3.getAddress() })

znode2.onRequest('foo', ({ body, reply }) => {
console.log(body)
reply('reply from znode2.')
})

let rep = await znode1.requestAny({
event: 'foo',
data: 'request from znode1.'
})

console.log(rep)
}())
Loading