public function suscribe($events, Closure $handler)
	{
		if (is_string($events)) $events = [$events];

		// store the handler for each of the events it represents
		foreach ($events as $event)
		{
			// check that we have a place to store the handler
			if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD]))
			{
				$this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = [];
			}

			$this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler;
		}

		// create a new bare message, and store the events
		$m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE);
		$m->Payload['Events'] = $events;

		// finally, send the message
		$this->send($m);
	}
public function suscribe($events, Closure $handler)
	{
		if (is_string($events)) $events = [$events];

		// store the handler for each of the events it represents
		foreach ($events as $event)
		{
			// check that we have a place to store the handler
			if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD]))
			{
				$this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = [];
			}

			$this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler;
		}

		// create a new bare message, and store the events
		$m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE);
		$m->Payload['Events'] = $events;

		// finally, send the message
		$this->send($m);
	}
public function suscribe ( $ events , Closure $ handler ) { if ( is_string ( $ events ) ) $ events = [ $ events ] ; // store the handler for each of the events it represents foreach ( $ events as $ event ) { // check that we have a place to store the handler if ( ! array_key_exists ( $ event , $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] ) ) { $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] [ $ event ] = [ ] ; } $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] [ $ event ] [ ] = $ handler ; } // create a new bare message, and store the events $ m = $ this -> bareMessage ( static :: MESSAGE_TYPE_SUSCRIBE ) ; $ m -> Payload [ 'Events' ] = $ events ; // finally, send the message $ this -> send ( $ m ) ; }
Suscribe to a given event

@param   string|[]  $event    the event to suscribe to
@param   Closure    $handler  the event handler to be called
upon receiving of the event
@return  void
Suscribe to a given event