git ssb

2+

Dominic / ssb-client



Tree:
📄README.md
📄index.js
📄package.json
README.md

ssb-client v1

scuttlebot client

var pull = require('pull-stream')
var ssbkeys = require('ssb-keys')
var ssbclient = require('ssb-client')

// generate a new keypair
var keys = ssbkeys.generate()

// connect to the local scuttlebot
var client = ssbclient(keys, 'localhost', doWork)

// listen to connection events
client.on('connect', function () {
  console.log('connection established, authenticating...')
})
client.on('authed', function () {
  console.log('authed and ready to go')
})
client.on('error', function (err) {
  // connection lost
  console.log('connection or authentication error', err)
  client.reconnect({ wait: 5000 })
})
client.on('reconnecting', function () {
  console.log('attempting reconnect...')
})

// make calls to the scuttlebot api
function doWork() {
  // authed and ready to go
  pull(client.createFeedStream(), pull.drain(console.log))
  client.publish({ type: 'post', text: 'hello, world!' }, console.log)
}

License

MIT, Copyright 2015 Paul Frazee and Dominic Tarr

Built with git-ssb-web