K�r event lokalt som anropas fr�n servern och som registrerats i ON-metod.
541222
public void InvokeEvent(String eventName, JSONArray args)
    {
        HubOnDataCallback subscription;
        if(mSubscriptions.containsKey(eventName))
        {
        	subscription = mSubscriptions.get(eventName);
            subscription.OnReceived(args);
        }
    }
442313
function(err, data) {
        var regexp = RegExp(/(Z\d)ON/);
        var ret;

        if (data) {
            for (i = 0; i < data.length; i++) {
                if (ret = regexp.exec(data[i])) {
                    zones[ret[1]] = ret[1];
                } else if (data[i] == 'PWON') {
                    zones['ZM'] = 'ZM';
                }
            }
        }
        mdt.telnet('RR?', handleZoneNames);
    }
1236268
function onServerMessage(message, rinfo) {

	var packet,
	    respond;

	alchemy.setStatus('multicast_messages', ++messages);

	try {
		packet = bson.deserialize(message);
	} catch(err) {
		log.warn('Received corrupt multicast message from ' + rinfo.address);
		return;
	}

	// Ignore packets that come from here
	if (packet.origin == alchemy.discovery_id) {
		return;
	}

	packet.remote = rinfo;

	if (packet.respond) {
		respond = function respond(data) {

			var response_packet = {
				type         : 'response',
				response_to  : packet.id,
				data         : data
			};

			submit(response_packet);
		};
	}

	// Emit it as a multicast event
	alchemy.emit('multicast', packet, respond, null);

	if (packet.response_to) {
		if (typeof callbacks[packet.response_to] === 'function') {
			callbacks[packet.response_to](packet.data, packet);
		}
	} else {
		// Emit it for multicast listeners only
		mevents.emit(packet.type, packet.data, packet, respond, null);
	}
}
313077
function eventSourceUnit (server) {
  var sources = {};

  function Source () {
    this.conn = [];
    this.history = [];
    this.lastMsgId = 0;
  }

  Source.prototype.removeConn = function(res) {
    var i = this.conn.indexOf(res);
    if (i !== -1) {
      this.conn.splice(i, 1);
    }
  };

  Source.prototype.sendSSE = function (res, id, event, message) {
    var data = '';
    if (event !== null) {
      data += 'event:' + event + '\n';
    }

    // Blank id resets the id counter.
    if (id !== null) {
      data += 'id:' + id + '\n';
    } else {
      data += 'id\n';
    }

    if (message) {
      data += 'data:' + message.split('\n').join('\ndata:') + '\n';
    }
    data += '\n';

    res.write(data);

    if (res.hasOwnProperty('xhr')) {
      clearTimeout(res.xhr);
      var self = this;
      res.xhr = setTimeout(function () {
        res.end();
        self.removeConn(res);
      }, 250);
    }
  };

  Source.prototype.emit = function (event, msg) {
    this.lastMsgId++;
    this.history.push({
      id: this.lastMsgId,
      event: event,
      msg: msg
    });

    for (var i = 0; i < this.conn.length; i++) {
      this.sendSSE(this.conn[i], this.lastMsgId, event, msg);
    }
  }

  Source.prototype.send = function (msg) {
    this.emit(null, JSON.stringify(msg));
  }

  function eventSource (channel) {
    if (channel[0] !== '/') { channel = '/$' + channel; }
    return sources[channel] = new Source();
  }

  server.eventSource = eventSource;


  return function eventSourceLayer (req, res, next) {
    if (sources[req.path] === undefined) return next();
    var source = sources[req.path];
    if (!source || req.headers.accept !== 'text/event-stream')
      return next();    // Don't bother if the client cannot handle it.

    // Remy Sharp's Polyfill support.
    if (req.headers['x-requested-with'] == 'XMLHttpRequest') {
      res.xhr = null;
    }

    res.setHeader('Content-Type', 'text/event-stream');
    res.setHeader('Cache-Control', 'no-cache');

    if (req.headers['last-event-id']) {
      var id = parseInt(req.headers['last-event-id']);
      for (var i = 0; i < source.history.length; i++)
        if (source.history[i].id > id)
          source.sendSSE(res, source.history[i].id,
              source.history[i].event, source.history[i].msg);
    } else res.write('id\n\n');      // Reset id.

    source.conn.push(res);

    // Every 15s, send a comment (avoids proxy dropping HTTP connection).
    var to = setInterval(function () {res.write(':\n');}, 15000);

    // This can only end in blood.
    req.on('close', function () {
      source.removeConn(res);
      clearInterval(to);
    });
  };
}
644313
function AnalyticsEventEmitter(logger, utils, CONSTANT, onErrorCallback, optionalArguments, serviceName) {
  'use strict';

  this.logger = logger || {};
  this.utils = utils || {};
  this.CONSTANT = CONSTANT || {};

  optionalArguments = optionalArguments || {};

  this.settings = optionalArguments.settings;
  this.reportEventDelay = optionalArguments.reportEventInterval;
  
  if(serviceName) {
    this.networkRequestServiceName = serviceName;
  }

  // Register onErrorCallback callback
  this.on('error', onErrorCallback || function (err) {
    this.logger.log('Emitted an error event: ' + err);
  });
}
1169973
function OpenEventObserver(clientPort, serverPort) {
    events.EventEmitter.call(this);

    this.isClientPortOpen = false;
    this.isServerPortOpen = false;

    clientPort.on('open', this._clientPortOpenHandler(this));
    serverPort.on('open', this._serverPortOpenHandler(this));
}
526719
function __fetchTicketInfo(server, ticketid, callback) {

    assert(server.cache_folder);

    var filename = server._ticket_cache_file(ticketid);
    //xx console.log("filename " , filename.red);

    assert(_.isFunction(callback));

    var command = 'issues/' + ticketid.toString() + '.json?include=relations,journals';

    perform_http_get_transaction(server,command, function (err, txt) {

        txt = fixUnicode(txt);

        var ticket = null;
        try {
            var o = JSON.parse(txt);

            fs.writeFileSync(filename, JSON.stringify(o, null, " "));
            console.warn(" writing ", filename);
            ticket= o.issue;
        } catch (err) {
            console.log("error !".red, err.message);
            fs.writeFileSync("toto.txt", txt);
            callback(err);
            return;
            // the ticket may have been deleted
        }
        callback(null,ticket);

    });

}
1183037
def events
      runtime.event_bus.register(
        :command_started,
        proc do |event|
          runtime.announcer.announce :command, event.entity.commandline
          runtime.announcer.announce :timeout, 'exit', event.entity.exit_timeout
          runtime.announcer.announce :timeout, 'io wait', event.entity.io_wait_timeout
          runtime.announcer.announce :wait_time, 'startup wait time', event.entity.startup_wait_time
          runtime.announcer.announce :full_environment, event.entity.environment
        end
      )

      runtime.event_bus.register(
        :command_started,
        proc do |event|
          runtime.command_monitor.register_command event.entity
          runtime.command_monitor.last_command_started = event.entity
        end
      )

      runtime.event_bus.register(
        :command_stopped,
        proc do |event|
          runtime.announcer.announce(:stdout) { event.entity.stdout }
          runtime.announcer.announce(:stderr) { event.entity.stderr }
          runtime.announcer.announce(:command_content) { event.entity.content }
          runtime.announcer.announce(:command_filesystem_status) { event.entity.filesystem_status }
        end
      )

      runtime.event_bus.register(
        :command_stopped,
        proc do |event|
          runtime.command_monitor.last_command_stopped = event.entity
        end
      )

      runtime.event_bus.register(
        [:changed_environment_variable, :added_environment_variable, :deleted_environment_variable],
        proc do |event|
          runtime.announcer.announce :changed_environment, event.entity[:changed][:name], event.entity[:changed][:value]
          runtime.announcer.announce :environment, event.entity[:changed][:name], event.entity[:changed][:value]
        end
      )

      runtime.event_bus.register(
        :changed_working_directory,
        proc { |event| runtime.announcer.announce :directory, event.entity[:new] }
      )

      runtime.event_bus.register(
        :changed_configuration,
        proc { |event| runtime.announcer.announce :configuration, event.entity[:changed][:name], event.entity[:changed][:value] }
      )
    end
270025
function messageHandler(msg, rinfo) {
  var msgStr = msg.toString();

  log.verbose(msgStr + ' <from: ' + rinfo.address + (rinfo.port ? ':' + rinfo.port : '') + '>');

  if (msg.length < 2) {
    return;
  }

  try {
    msg = JSON.parse(msgStr);
  } catch (e) {
    log.debug(e.stack || e.message || e);
    return;
  }

  if (!_.isPlainObject(msg)) {
    return;
  }

  // check for health check request
  if (msg.healthCheck) {
    // respond to health check and exit function
    var resp = JSON.stringify({status: (this.dropEvents ? 'backlogged' : 'ok')});

    try {
      this.server.send(resp, 0, resp.length, rinfo.port, rinfo.address, function (err) {
        if (err) {
          log.debug(err.stack || err.message || err);
        }
      });
    } catch (err) {
      log.debug(err.stack || err.message || err);
    }

    return;
  }

  if (_.isUndefined(msg.routingKey) || !_.isString(msg.routingKey) || !msg.routingKey) {
    return;
  }

  // remove illegal characters from the routing key
  msg.routingKey = msg.routingKey.replace(/[^-\.\w]/g, '');

  if (!msg.routingKey) {
    return;
  }

  if (this.dropEvents) {
    // track drop stats
    if (_.isFunction(process.send)) {
      try {
        process.send({event: 'updateEventDropStats', data: msg});
      } catch (err) {
        log.debug(err.stack || err.message || err);
      }
    }

    // last ditch effort to process event
    // hope another eventsd server is not backlogged
    if (process.env.SZ_EVENTSD_HOST && process.env.SZ_EVENTSD_PORT) {
      log.verbose('resending event to eventsd');

      try {
        var sock = new dgram.createSocket('udp4');
        var message = JSON.stringify(msg);

        sock.send(message, 0, message.length, process.env.SZ_EVENTSD_PORT, process.env.SZ_EVENTSD_HOST, function (err) {
          if (err) {
            log.verbose(err.stack || err.message || err);
          }
        });
      } catch (err) {
        log.verbose(err.stack || err.message || err);
      }
    }

    return;
  }

  // track event stats
  if (_.isFunction(process.send)) {
    try {
      process.send({event: 'updateEventStats', data: msg});
    } catch (err) {
      log.debug(err.stack || err.message || err);
    }
  }

  // publish to firehose
  this.publisher.publish(msg, {contentType: 'application/json'}, msg.routingKey);
}
216660
function addParserEvents(parser) {
  parser.onopentag = parser_opentag;
  parser.onclosetag = parser_closetag;
  parser.ontext = parser_text;
  parser.oncdata = parser_cdata;
}
842603
def _domain_event_graphics_cb(conn, domain, phase, local, remote, auth, subject, opaque):
    '''
    
    '''
    prefix = 'VIR_DOMAIN_EVENT_GRAPHICS_'

    def get_address(addr):
        '''
        transform address structure into event data piece
        '''
        return {'family': _get_libvirt_enum_string('{0}_ADDRESS_'.format(prefix), addr['family']),
                'node': addr['node'],
                'service': addr['service']}

    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'phase': _get_libvirt_enum_string(prefix, phase),
        'local': get_address(local),
        'remote': get_address(remote),
        'authScheme': auth,
        'subject': [{'type': item[0], 'name': item[1]} for item in subject]
    })
766791
@Override
    public void onEvent(EventIterator events) {
        try {
            // this resolver should be the only one (for this handling thread)
            ResourceResolver resolver = getResolver();
            if (resolver != null) {
                try {
                    Session session = resolver.adaptTo(Session.class);
                    String serviceUserId = getServiceUserId();
                    // collect changed nodes
                    ChangeCollection changedNodes = new ChangeCollection();
                    while (events.hasNext()) {
                        Event event = events.nextEvent();
                        if (ignoreEvent(event)) continue;
                        try {
                            String path = event.getPath();
                            String user = event.getUserID();
                            // if the service user is the initiator this is a self initiated event - ignore it
                            if (!serviceUserId.equals(user)) {
                                Calendar time = Calendar.getInstance();
                                time.setTime(new Date(event.getDate()));
                                int type = event.getType();
                                if (isPropertyEvent(type)) {
                                    if (getPropertyPathFilter().accept(path)) {
                                        changedNodes.registerChange(session, resolver, path, time, user);
                                    }
                                } else {
                                    if (getNodePathFilter().accept(path)) {
                                        changedNodes.registerChange(session, resolver, path, time, user);
                                    }
                                }
                            }
                        } catch (RepositoryException rex) {
                            LOG.error(rex.getMessage(), rex);
                        }
                    }
                    // handle change actions on the detected nodes
                    if (changedNodes.size() > 0) {
                        for (ChangedResource change : changedNodes.values()) {
                            try {
                                doOnChange(resolver, change);
                            } catch (RepositoryException ex) {
                                LOG.error(ex.getMessage(), ex);
                            }
                        }
                        changedNodes.clear();
                        resolver.commit();
                    }
                } catch (PersistenceException ex) {
                    LOG.error(ex.getMessage(), ex);
                } finally {
                    resolver.close();
                }
            }
        } catch (LoginException ex) {
            LOG.error(ex.getMessage(), ex);
        }
    }
66280
protected function fireEvents()
    {
        array_map(function (VkRequest $request, $response) {
            $status = isset($response['error_code']) ? VkRequest::STATUS_FAIL : VkRequest::STATUS_SUCCESS;
            $event = sprintf(VkRequest::EVENT_FORMAT, $status, $request->method, $request->tag);
            event($event, [$request, $response]);
        }, $this->requests->all(), $this->responses);
    }
642519
function addParserEvents(parser) {
  parser.onopentag = parser_opentag;
  parser.onclosetag = parser_closetag;
  parser.ontext = parser_text;
  parser.oncdata = parser_cdata;
  parser.oncomment = parser_comment;
  parser.ondoctype = parser_doctype;
  parser.onerror = parser_error;
}
1273609
def cli(env, ack_all):
    """"""

    manager = AccountManager(env.client)
    events = manager.get_upcoming_events()

    if ack_all:
        for event in events:
            result = manager.ack_event(event['id'])
            event['acknowledgedFlag'] = result
    env.fout(event_table(events))
114400
function(rpc_method, fn) {
        rpc.on(rpc_method, _.partial(moduleEventWrap, rpc_method, fn));
    }
360436
def events(self, all_instances=None, instance_ids=None, filters=None):
        """"""
        params = {}
        if filters:
            params["filters"] = make_filters(filters)
        if instance_ids:
            params['InstanceIds'] = instance_ids
        statuses = self.status(all_instances, **params)
        event_list = []
        for status in statuses:
            if status.get("Events"):
                for event in status.get("Events"):
                    event[u"InstanceId"] = status.get('InstanceId')
                    event_list.append(event)
        return event_list