API Methods

SkynetEventListenerAbstract base class offers to your listener some of useful API method to use.

Most important of them are request and response objects, but there is more:

Request and Response


This is the main Request object


This is the main Response object


Read only array with requests fields indexed by fields keys


Read only array with response fields indexed by fields keys


$this->reg_set('foo', 'bar');

Registry option set

$foo = $this->reg_get('foo');

Registry option get


$this->opt_set('foo', 'bar');

System option set

$foo = $this->opt_get('foo');

System option get

Monits and Logs

$this->addMonit('monit message');

Creates monit message

$this->addLog('log message');

Creates log message



Debugs (dumps) variable/array/object

$this->debug->txt('debug message');

Adds debug message

Clusters informations


Address of request/response sender


Address of request/response receiver


Address of actual cluster

Events and connections informations


Name of actual event


Name of actual context


Number of actual connection


True if listener was called from request sender, False if listener was called from responder

Core objects


Authorization object


Database object


Verifier object

Of course, you can use more of Skynet objects, like Logger, Emailer or Console by create its instances.
Full API reference you will find in API Documentation.

Example of API methods usage:

public function onResponse($context)
  if($context == "beforeSend")
    /* If request field 'foo' is set */
    if($this->request->get('foo') !== null)
      /* get value of request field 'foo' */
      $foo = $this->request->get('foo');
      /* if request field 'foo' has value 'bar' */ 
      if($foo == 'bar')
        /* set response field 'bar' with value 'Foo is Bar' */
        $this->response->set('bar', 'Foo is Bar');
        /* set monit to show about receive 'bar' */
        $this->addMonit('Received Bar');
        /* set registry field 'foo' to 'bar' if actual value is not 'bar' */
        if($this->reg_get('foo') != 'bar')
          $this->reg_set('foo', 'bar');
      /* if request field 'foo' is not 'bar' */
      } else {
        /* set response and debug field 'foo' */
        $this->response->set('bar', 'Foo is not Bar');
        $this->debug->txt('Foo is not Bar');
    /* set monits about sender and receiver */
    $this->addMonit('Request received from:'. $this->receiverClusterUrl);
    $this->addMonit('Sending response from:'. $this->senderClusterUrl);
    /* save log */
    $this->addLog('Log from cluster: '.$this->myAddress.' from event: '.$this->eventName.' with context: '.$this->context);
    /* check option 'sleep' from options table */
    if($this->opt_get('sleep') == 0)
      $this->addLog('My cluster is not sleeped');
      /* if code here was called from responder then save log */
        $this->addLog('Log saved from responder');
    /* generate monit with actual response fields */
    $responseString = '';
    foreach($this->responseData as $key => $value)
      $responseString.= $key.':'.$value.',';      
    $this->addMonit('Actual response fields:'. $responseString);
Full API Documentation is included in Skynet packages available on GitHub.