2019-11-01 18:30:06 +00:00
|
|
|
var client = require('../../lib/dist');
|
2017-01-29 02:04:58 +00:00
|
|
|
var uuid = require('uuid');
|
|
|
|
|
|
|
|
var settings = {
|
|
|
|
log: {
|
|
|
|
info: console.log,
|
|
|
|
error: console.log,
|
|
|
|
debug: console.log
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var gossipSeeds = [
|
2017-01-29 18:57:59 +00:00
|
|
|
new client.GossipSeed({host: '192.168.33.10', port: 2113}),
|
|
|
|
new client.GossipSeed({host: '192.168.33.11', port: 2113}),
|
|
|
|
new client.GossipSeed({host: '192.168.33.12', port: 2113})
|
2017-01-29 02:04:58 +00:00
|
|
|
];
|
|
|
|
var conn = client.createConnection(settings, gossipSeeds);
|
|
|
|
console.log('Connecting...');
|
|
|
|
conn.on('connected', function (tcpEndPoint) {
|
2017-01-29 18:57:59 +00:00
|
|
|
console.log('Connected to', tcpEndPoint);
|
2017-01-29 02:04:58 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
conn.appendToStream('test-' + uuid.v4(), client.expectedVersion.noStream, [
|
|
|
|
client.createJsonEventData(uuid.v4(), {abc: 123}, {}, 'myEvent')
|
|
|
|
]);
|
|
|
|
}, 5000);
|
|
|
|
});
|
|
|
|
conn.on('error', function (err) {
|
|
|
|
console.log(err.stack);
|
|
|
|
});
|
|
|
|
conn.on('closed', function (reason) {
|
|
|
|
console.log('Connection closed:', reason);
|
|
|
|
process.exit(-1);
|
|
|
|
});
|
|
|
|
conn.connect()
|
|
|
|
.catch(function (err) {
|
|
|
|
console.log(err.stack);
|
|
|
|
process.exit(-1);
|
|
|
|
});
|