dominictarr / scuttlebutt

peer-to-peer replicatable data structure
Other
1.32k stars 66 forks source link

Documentation , dosnt include client side code for connecting to a tcp server #37

Open doronaviguy opened 10 years ago

doronaviguy commented 10 years ago

When i first i looked at readme , i couldnt find the peace of code for the clients, to connect to the the tcp server ,

var Model = require('scuttlebutt/model');
var net = require('net');

var m = new Model;
var s = m.createStream();

s.pipe(net.connect(8888, 'localhost')).pipe(s);

m.on('update', function cb (key) {
    // wait until we've gotten at least one count value from the network
    if (key !== 'count') return;
    m.removeListener('update', cb);

    setInterval(function () {
        m.set('count', Number(m.get('count')) + 1);
    }, 100);
});

m.on('update', function (key, value) {
    console.log(key + ' = ' + value);
});
dominictarr commented 10 years ago

the example in the readme includes the client and the server code. https://github.com/dominictarr/scuttlebutt#replication

doronaviguy commented 10 years ago

yep , guess i just missed it . thoguh i was looking for a server client exmpale, i guess thats why i didnt notice , the connect example. Great module, i enjoy. I was looking for module like that for a while , now . and i couldnt find it .

Julian Gruber told me about that module . and thats exactly what i need

On Tue, Sep 16, 2014 at 5:36 PM, Dominic Tarr notifications@github.com wrote:

the example in the readme includes the client and the server code. https://github.com/dominictarr/scuttlebutt#replication

— Reply to this email directly or view it on GitHub https://github.com/dominictarr/scuttlebutt/issues/37#issuecomment-55752293 .