Skip to content

Instantly share code, notes, and snippets.

@uiur
Created June 6, 2015 14:44
Show Gist options
  • Save uiur/57e5d49e1fd3d2b7d935 to your computer and use it in GitHub Desktop.
Save uiur/57e5d49e1fd3d2b7d935 to your computer and use it in GitHub Desktop.
// 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