Event handler for incoming Z-Wave events. We monitor Z-Wave events for completed
transactions. Once a transaction is completed for the WAKE_UP_NO_MORE_INFORMATION
event, we set the node state to asleep.
{@inheritDoc}
502045
@Override
	public void ZWaveIncomingEvent(ZWaveEvent event) {
		if (event.getEventType() != ZWaveEvent.ZWaveEventType.TRANSACTION_COMPLETED_EVENT)
			return;
		
		SerialMessage serialMessage = (SerialMessage)event.getEventValue();
		
		if (serialMessage.getMessageClass() != SerialMessage.SerialMessageClass.SendData && serialMessage.getMessageType() != SerialMessage.SerialMessageType.Request)
			return;
		
		byte[] payload = serialMessage.getMessagePayload();
		
		if (payload.length < 4)
			return;
		if ((payload[0] & 0xFF) != this.getNode().getNodeId())
			return;
		if ((payload[2] & 0xFF) != this.getCommandClass().getKey())
			return;
		if ((payload[3] & 0xFF) != WAKE_UP_NO_MORE_INFORMATION)
			return;
		
		logger.debug("Node {} went to sleep", this.getNode().getNodeId());
		this.setAwake(false);
	}
1214051
@Override
  public void eventReceived(EventSubscriptionEntity eventSubscriptionEntity, Object payload, boolean processASync) {
    if (processASync) {
      scheduleEventAsync(eventSubscriptionEntity, payload);
    } else {
      processEventSync(eventSubscriptionEntity, payload);
    }
  }
235058
public function event( $event ) 
	{
		// call the wake event
		if ( is_string( $this->namespace ) ) 
		{
			if ( strpos( $event, '::' ) !== false ) 
			{
				$callback = explode( '::', $event );
				$class = $this->namespace."\\".$callback[0];
				
				if ( class_exists( $class ) ) 
				{
					call_user_func( array( $this, $callback[1] ) );
				}
			} 
			else 
			{
				if ( is_file( $this->path.$event ) ) 
				{
					require $this->path.$event;
				}
			}
		} 
		else
		{
			if ( is_file( $this->path.$event ) )
			{
				require $this->path.$event;
			}
		}
	}
1194880
public function onClose()
    {
        if ($this->realm !== null) {
            // only send the leave metaevent if we actually made it into the realm
            if ($this->isAuthenticated()) {
                // metaevent
                $this->getRealm()->publishMeta('wamp.metaevent.session.on_leave', [$this->getMetaInfo()]);
            }
            $this->dispatcher->dispatch('LeaveRealm', new LeaveRealmEvent($this->realm, $this));

            $this->realm = null;
        }
    }
995456
@Override
  public void onNext(final T event) {
    final EventHandler<T> handler = (EventHandler<T>) map.get(event.getClass());
    if (handler == null) {
      throw new WakeRuntimeException("No event " + event.getClass() + " handler");
    }
    handler.onNext(event);
  }
922251
protected function listen()
    {
        $this->eventEmitter->on('peridot.concurrency.load', [$this, 'setPending']);
        $this->eventEmitter->on('peridot.concurrency.worker.run', [$this, 'addRunning']);
        $this->eventEmitter->on('peridot.concurrency.worker.completed', [$this, 'onWorkerComplete']);
        $this->broker->on('end', [$this, 'onMessageEnd']);
        $this->broker->on('error', [$this, 'onError']);
        $this->broker->on('suite.halt', [$this, 'stop']);
    }
903047
protected function listen()
    {
        $this->eventEmitter->on('peridot.concurrency.pool.start-workers', [$this, 'onWorkersStart']);
        $this->eventEmitter->on('peridot.concurrency.worker.error', [$this, 'onError']);
        $broker = $this->pool->getMessageBroker();
        $broker->on('suite.start', [$this, 'onSuiteStart']);
        $broker->on('suite.end', [$this, 'onSuiteEnd']);
        $broker->on('test.passed', [$this, 'onTestPassed']);
        $broker->on('test.failed', [$this, 'onTestFailed']);
        $broker->on('test.pending', [$this, 'onTestPending']);
    }
704232
private void handleFailedSendDataRequest(SerialMessage originalMessage) {
		ZWaveNode node = this.getNode(originalMessage.getMessageNode());
		
		if (node.getNodeStage() == NodeStage.NODEBUILDINFO_DEAD)
			return;
		
		if (!node.isListening() && originalMessage.getPriority() != SerialMessage.SerialMessagePriority.Low) {
			ZWaveWakeUpCommandClass wakeUpCommandClass = (ZWaveWakeUpCommandClass)node.getCommandClass(ZWaveCommandClass.CommandClass.WAKE_UP);
			
			if (wakeUpCommandClass != null) {
				wakeUpCommandClass.setAwake(false);
				wakeUpCommandClass.putInWakeUpQueue(originalMessage); //it's a battery operated device, place in wake-up queue.
				return;
			}
		} else if (!node.isListening() && originalMessage.getPriority() == SerialMessage.SerialMessagePriority.Low)
			return;
		
		node.incrementResendCount();
		
		logger.error("Got an error while sending data to node {}. Resending message.", node.getNodeId());
		this.sendData(originalMessage);
	}
738202
public function onReady()
    {
        if ($this->isEnabled()) {
            $this->updateTimer = setTimeout(function ($timer) {
                $this->updateAllServers();
                $timer->timeout(2e6);
            }, 1);
        }
    }
348131
public final ZEvent nextEvent(boolean wait)
    {
        if (!started) {
            System.out.println("ZMonitor: Start before getting events.");
            return null;
        }
        ZMsg msg = agent.recv(wait);
        if (msg == null) {
            return null;
        }
        return new ZEvent(msg);
    }
46273
private void onConnectionClosed()
   {
      ConnectionEvent evt = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
      for (ConnectionEventListener listener : listeners)
      {
         try
         {
            listener.connectionClosed(evt);
         }
         catch (Exception e1)
         {
            LOG.warn("An error occurs while notifying the listener " + listener, e1);
         }
      }
   }
804858
public function onConnected($cb)
    {
        if ($this->state === self::CONN_STATE_HANDSHAKED_ERROR) {
            $cb($this);
        } elseif ($this->state === self::CONN_STATE_HANDSHAKED_OK) {
            $cb($this);
        } else {
            if (!$this->onConnected) {
                $this->onConnected = new StackCallbacks();
            }

            $this->onConnected->push($cb);
        }
    }
554265
static function cleanup()
    {
        $availableHandlers = eZNotificationEventFilter::availableHandlers();

        $db = eZDB::instance();
        $db->begin();
        foreach( $availableHandlers as $handler )
        {
            if ( $handler !== false )
            {
                $handler->cleanup();
            }
        }
        $db->commit();
    }
554966
def echo_node_alarm_callback(self, block_number):
        
        if not self.ready.is_set():
            self.ready.set()
        log.debug('echo_node callback', block_number=block_number)
        if self.stop_signal is not None:
            return REMOVE_CALLBACK
        else:
            self.greenlets.add(gevent.spawn(self.poll_all_received_events))
            return True
235928
private void handleDeadNode(String nodeName, Set<String> sessions) {
    LOG.info("Notify sessions: " + sessions + " about dead node " + nodeName);
    for (String session : sessions) {
      sessionNotifier.notifyDeadNode(session, nodeName);
    }
  }
1074750
public function eventCall()
    {
        try {
            //Daemon::log('cb - '.Debug::zdump($this->cb));
            $func = $this->cb;
            $func($this);
        } catch (\Exception $e) {
            Daemon::uncaughtExceptionHandler($e);
        }
    }
61244
function ProcessWatcher(pid, parent) {
    var self = this;

    this.dead = false;

    // check first if process is alive
    if (exports.alive(pid) === false) {
      process.nextTick(function () {
        self.dead = true;
        self.emit('dead');
      });
      return self;
    }

    // use disconnect to detect parent death
    if (parent && exports.support.disconnect) {
      var listen = function() {
        self.dead = true;
        self.stop();
        self.emit('dead');
      }

      parent.once('disconnect', listen);
      this.stop = parent.removeListener.bind(null, 'disconnect', listen);

      this.on('newListener', function (eventName) {
        if (eventName !== 'cycle') return;

        process.nextTick(function () {
          self.emit('cycle');
        });
      });

      return self;
    }

    // fallback to an setInterval try/catch check
    var timer = setInterval(function () {
      if (exports.alive(pid) === false) {
        self.dead = true;
        self.stop();
        self.emit('dead');
      }
      self.emit('cycle');
    });
    this.stop = clearInterval.bind(null, timer);
  }