git ssb

1+

cheerbitch / dexbot



Commit 3c7412cfacd39dd1c55f757380a9d54c64547705

wow so many

Tree committed on 12/14/2016, 8:10:20 AM
Parent: ea25afa4464d1c2785f2e0f8e88045b24021891d

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -3,20 +3,44 @@
33 var muxrpc = require('muxrpc')
44 var ms = require('multiserver')
55 var mdns = require('bonjour')()
66
7 +var sublevel = require('level-sublevel')
8 +var memdb = sublevel(require('memdb')())
9 +
10 +var hyperlog = require('hyperlog')
11 +var ps = require('pull-stream')
12 +var str2ps = require('stream-to-pull-stream')
13 +
714 var createApp = secretStack({
8- appKey: new Buffer('00000000000000000000000000000000')
15 + appKey: new Buffer('00000000000000000000000000000000'),
16 + timers: {
17 + inactivity: 0,
18 + handshake: 0
19 + }
920 }).use({
1021 name: 'spot',
1122 manifest: {
12- greet: 'async'
23 + greet: 'async',
24 + createLog: 'duplex'
1325 },
1426 permissions: {
15- anonymous: ['public.greet']
27 + anonymous: ['greet', 'createLog']
1628 },
1729 init: function(api, opts){
1830 return {
31 + 'createLog': function(name){
32 + var log = hyperlog(memdb.sublevel(name))
33 + var stream = str2ps.duplex(log.replicate({live:true}), function(err){
34 + //console.log('remote error or completion?', err)
35 + })
36 + setInterval(function(){
37 + log.add(null, Math.random().toString(2), function(err, msg){
38 + if(err) console.log(err)
39 + })
40 + },1511)
41 + return stream
42 + },
1943 'greet': function(cb){
2044 cb(null, 'GREETINGS')
2145 }
2246 }
@@ -36,17 +60,28 @@
3660
3761 mdns.publish(record)
3862
3963 mdns.find({type: 'spot'}, function(service){
40- console.log(service)
4164 if(service.host === node.getAddress()) return
4265 else{
4366 node.connect(service.host, function(err, rpc){
44- console.log(err, rpc)
67 + if(err) console.log(err)
68 + //console.log(err, rpc)
4569 rpc.spot.greet(function(err, greets){
4670 console.log(greets)
4771 })
48- })
72 + var log = hyperlog(memdb.sublevel())
73 + var local = str2ps.duplex(log.replicate({live : true}), function(err){
74 + //console.log('local err or ending?', err)
75 + })
76 + var remote = rpc.spot.createLog()
77 + var x
78 + ps(local, remote, local)
79 +
80 + log.on('add', function(data){
81 + console.log(data.value.toString())
82 + })
83 + })
4984 }
5085 })
5186
5287 console.log(node.getAddress())
package.jsonView
@@ -11,10 +11,15 @@
1111 "author": "",
1212 "license": "ISC",
1313 "dependencies": {
1414 "bonjour": "^3.5.0",
15 + "hyperlog": "^4.11.0",
16 + "level-sublevel": "^6.6.1",
17 + "memdb": "^1.3.1",
18 + "pull-stream": "^3.5.0",
1519 "secret-stack": "^3.2.0",
16- "ssb-keys": "^7.0.3"
20 + "ssb-keys": "^7.0.3",
21 + "stream-to-pull-stream": "^1.7.2"
1722 },
1823 "devDependencies": {},
1924 "repository": {
2025 "type": "git",

Built with git-ssb-web