gui\Application::sendCommand PHP Method

sendCommand() public method

Send a command
public sendCommand ( string $method, array $params, callable $callback ) : void
$method string the method name
$params array the method params
$callback callable the callback
return void
    public function sendCommand($method, array $params, callable $callback)
    {
        // @todo: Put the message on a poll
        if (!$this->running) {
            return;
        }
        $message = new CommandMessage($method, $params, $callback);
        $this->sender->send($message);
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function on($eventName, callable $eventHandler)
 {
     $eventName = 'on' . $eventName;
     $this->application->sendCommand('setObjectEventListener', [$this->lazarusObjectId, $eventName], function ($result) {
         // Ok, the event listener created
     });
     if (!array_key_exists($eventName, $this->eventHandlers)) {
         $this->eventHandlers[$eventName] = [];
     }
     $this->eventHandlers[$eventName][] = $eventHandler;
 }