Created
June 6, 2015 14:44
-
-
Save uiur/57e5d49e1fd3d2b7d935 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// seeding | |
swarm.on('peer', function (peer) { | |
dht.addPeer(peer) | |
}) | |
// signaling | |
// hub | |
hub.subscribe('/channel') | |
// peer | |
rpc.request('proxy', { id: 'aaa', data: {} }) | |
rpc.on('proxy') | |
// rpc server | |
{ | |
type: 'request', | |
method: 'ping' | |
} | |
{ | |
type: 'response', | |
method: 'findValue', | |
key: 'hoge', | |
value: 'foo' | |
} | |
rpc.request('findValue', { key: 'hoge' }) | |
rpc.on('ping', function (req, res) { | |
res() | |
}) | |
rpc.on('findValue', function (req, res) { | |
res({ value: 'value' }) | |
}) | |
// rpc list | |
rpc.request('list') | |
rpc.on('list', function (req, res) { | |
db.get('list', res) | |
}) | |
// dht | |
dht.get('key', function (err, value) {}) | |
dht.put('key', 'value', function (err) {}) | |
// entry | |
{ | |
title: 'title', | |
body: 'body', | |
timestamp: 'timestamp' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment