Created
October 26, 2014 01:25
-
-
Save jtremback/cfaa53aa0376032982af to your computer and use it in GitHub Desktop.
Don't understand why this doesn't work
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
'use strict'; | |
var pull = require('pull-stream') | |
var net = require('net') | |
var toStream = require('pull-stream-to-stream') | |
var rimraf = require('rimraf') | |
rimraf.sync('./following1.db') // delete the db from last time | |
var ssb1 = require('../create')('./following1.db') | |
var feed1 = ssb1.createFeed() | |
rimraf.sync('./following2.db') // delete the db from last time | |
var ssb2 = require('../create')('./following2.db') | |
var feed2 = ssb2.createFeed() | |
var count = 0; | |
setInterval(function () { | |
feed1.add('msg', 'hello there! ' + count++, function () {}) | |
}, 2000) | |
feed2.add({ | |
type: 'follow', | |
follows: { $feed: feed1.id, $rel: 'follows' } | |
}, function () {}) | |
net.createServer(function (connection) { | |
connection.pipe(toStream(ssb1.createReplicationStream())).pipe(connection); | |
}).listen(1234); | |
var connection = net.connect(1234) | |
connection.pipe(toStream(ssb2.createReplicationStream())).pipe(connection) | |
pull( | |
ssb2.createFeedStream({ tail: true }), | |
pull.drain(function (message) { | |
console.log('MESSAGE: ', message) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment