Beispiel #1
0
Client.prototype.connect = function(addr){
  debug('connect %s', addr);
  assert('string' == typeof addr, 'address string required');
  var node = new Node(addr, this.opts);
  fwd(node, this);
  this.watchState(node);
};
Beispiel #2
0
  .then(last_sync => {
    const opts = {
      push: { since: last_sync.push.last_seq },
      pull: { since: last_sync.pull.last_seq }
    }

    const syncEvt = db.sync(remote, opts)
    forward(syncEvt, evt) // forward all sync events
    syncEvt.on('complete', info => {
      last_sync.push.last_seq = info.push.last_seq
      last_sync.pull.last_seq = info.pull.last_seq
      db.put(last_sync)
    })
  })
Beispiel #3
0
  initMusic: function () {
    // If we need to add scripts
    this.googleMusic = this.googleWindow.googleMusic;
    if (!this.googleMusic) {
      // Bind to the window
      this.googleMusic = this.googleWindow.googleMusic = new GoogleMusic(this.googleWindow);

      // Forward all events
      forwardEvents(this.googleMusic, this);

      // Emit an event
      this.emit('init-music');
    }
  },
Beispiel #4
0
function Client(opts) {
  if (!(this instanceof Client)) return new Client(opts);
  opts = opts || {};
  this.sock = dgram.createSocket('udp4');
  this.host = opts.host || 'localhost';
  this.port = opts.port || 8125;
  this.tags = {
    'node_env': process.env.NODE_ENV,
    'service': opts.service
  };
  this.sample_rate = opts.sample_rate || 1;
  fwd(this.sock, this);
  this.on('error', this.onerror.bind(this));
}
Beispiel #5
0
 Object.keys(m.sublevels).forEach(function(name){
   var sub = monitor(db.sublevel(name), { sublevel: name });
   fwd(sub, events);
 });