Send/receive commands

Skynet commands are special types od parameters. They are requests for some kind of action to be executed. Commands are similar to parameters but prefixed by "@".
Every parameter with name prefixed that is interpreted by Skynet as a command. Commands can take parameter (or parameters) and can be call from PHP code (via Event Listeners) or via webconsole or command line in CLI mode.

Let's look at the example.
In previous section we was sending parameter foo to skynet2.php cluster. We defined receiver cluster by:


This parameter is one of the commands in Skynet.
With command you can send to another clusters a request to execute specified by command action, like set value in database, or launch any other action. You can define actions for received commands in Event Listeners:

public function onRequest($context)
if($context == "afterReceive")
/* do something */

where @COMMAND_NAME is name of command sended by:

$this->request('set', '@COMMAND_NAME');



in webconsole.

Special type of commands is:


It's not called "return", but its called by single "@" char.
When parameter returned with response is prefixed by "@" and not "@<<" that is exacly the echo command. This command do nothing but returns parameters sended in request. You can disable this option (include sended data in response) in config file.

Another special type od command is "Skynet control parameter".
Those commands are prefixed by "_skynet" (not by "@") and controls connection params.
You should not use prefix _skynet in your own defined parameters and commands becose this prefixes are reserved for Skynet internal core.

Commands can take arguments, e.g. when you're setting receiver cluster address by:

$this->request->set('@to', 'CLUSTER_ADDRESS');

CLUSTER_ADDRESS is here an argument of command @to.

If you want to specify argument by webconsole, you must add it after space, e.g.:


(press "Send request")

You can pass multiple arguments to some commands by separating them with coma -"," e.g.:


(clusters addresses without quotes)

Usage in CLI is similar to defining parameters:


You will find full commands list in section "Skynet Commands". Of course you can (and you should) define your own commands in your own Event Listeners to extends Skynet for functionality as you need.
Full API Documentation is included in Skynet packages available on GitHub.