node.js - Nodejs JavaScript Events -
given code above:
binaryserver = binaryserver({port: 9001}); binaryserver.on('connection', function(client) { console.log("new connection"); client.on('stream', function(stream, meta) { console.log('new stream'); stream.on('data', function('data'){ //actions stream.on('end', function() { //actions }); }); });
i can client
inherits features of binaryserver
. if make console.log(client.id)
in events of stream
can see, client generate given event. want know if every single event exclusive of 1 client, in other words want know if data
happens every single client (that generates data) , no data event
generated while actions
happening.
you're registering listener "connection" event can happen within binaryserver
. when "connection" event happens, registered listener receive argument, choose call client
. client
in case object, , doesn't inherit features of binaryserver
.
"data" happens every client
, have unique results each client
since register event listener every client
.
if 2 events triggered after each other, callback function of first event called, , after second events callback function called. see following example code:
var event = new event('build'); var = 0; // listen event. document.addeventlistener('build', function (e) { console.log(i++); }, false); // dispatch event. document.dispatchevent(event); document.dispatchevent(event);
Comments
Post a Comment