How to use the events.EventEmitter.call function in events

To help you get started, we’ve selected a few events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BonsaiDen / NodeGame-Orbit / server / libs / ws.js View on Github external
function Connection(req, socket, upgradeHeader) {

    EventEmitter.call(this);

    var headers = this.headers = this.request(req);
    this.version = -1;
    this.socket = socket;

    this.bytesSend = 0;
    this.bytesReceived = 0;
    this.rawBytesSend = 0;
    this.rawBytesReceived = 0;
    this.connected = false;

    // Newer drafts
    if ('version' in headers && 'origin' in headers) {

        if (this.headers.version === 8) {
github pillarsjs / pillars / lib / Beam.js View on Github external
function Beam(config){
	EventEmitter.call(this);
	var beam = this;
	var noconfig = (typeof config === 'function');
	var worklist = Array.prototype.slice.call(arguments).slice(noconfig?0:1);

	var config = noconfig?{}:(config || {});
	beam.config = config;

	var id = config.id || Date.now().toString(36)+Math.round(Math.random()*10).toString(36);
	Object.defineProperty(beam,"id",{
		enumerable : true,
		get : function(){return id;},
		set : function(set){
			beam.emit("idUpdate",id,set);
			id = set;
		}
	});
github apache / thrift / lib / nodejs / lib / thrift / connection.js View on Github external
var StdIOConnection = exports.StdIOConnection = function(command, options) {
  var command_parts = command.split(' ');
  command = command_parts[0];
  var args = command_parts.splice(1,command_parts.length -1);
  var child = this.child = child_process.spawn(command,args);

  var self = this;
  EventEmitter.call(this);

  this.connection = child.stdin;
  this.options = options || {};
  this.transport = this.options.transport || TBufferedTransport;
  this.protocol = this.options.protocol || TBinaryProtocol;
  this.offline_queue = [];

  if (log.getLogLevel() === 'debug') {
    this.child.stderr.on('data', function (err) {
      log.debug(err.toString(), 'CHILD ERROR');
    });

    this.child.on('exit', function (code,signal) {
      log.debug(code + ':' + signal, 'CHILD EXITED');
    });
  }
github danielwippermann / resol-vbus / src / header-set.js View on Github external
constructor: function(options) {
        EventEmitter.call(this);

        this.headerList = [];

        _.extend(this, _.pick(options, optionKeys));

        if (!this.timestamp) {
            this.timestamp = new Date();
        }

        if (_.has(options, 'headers')) {
            this.addHeaders(options.headers);
        }
    },
github fontello / fontello / lib / system / init / server.js View on Github external
function WorkerPool(size, worker) {
  if (!(this instanceof WorkerPool)) return new WorkerPool(size, worker);

  EventEmitter.call(this);

  this.__workers = [];
  this.__wClass  = worker;
  this.__size    = 0;

  this.update = _.debounce(() => {
    process.nextTick(() => {
      this.resize();
      this.gc();
    });
  }, 100, { maxWait: 200 });

  this.resize(size);
}
github hflw / node-robot / lib / scheduler.js View on Github external
var Scheduler = module.exports = function(manualStart){
  this.sequences = [];
  this.currentSequence = null;
  this.active = false; //true when running a sequence
  this.started = false;

  EventEmitter.call(this);

  if(!manualStart)
    this.start();
}
github mjackson / mach / modules / multipart / Content.js View on Github external
function Content() {
  EventEmitter.call(this);
  this.readable = true;
  setupContent(this);
}
github bang-olufsen / create / beocreate_essentials / sources.js View on Github external
function SourceManager() {
if (! (this instanceof SourceManager)) return new SourceManager();
	this.sources = [];
	
	eventEmitter.call(this);
}
github facebook / watchman / node / index.js View on Github external
function Client(options) {
  var self = this;
  EE.call(this);

  this.watchmanBinaryPath = 'watchman';
  if (options && options.watchmanBinaryPath) {
    this.watchmanBinaryPath = options.watchmanBinaryPath.trim();
  };
  this.commands = [];
}
util.inherits(Client, EE);