PHPDaemon\Network\Client::requestByKey PHP Method

requestByKey() public method

Sends a request to server according to the key
public requestByKey ( string $key, string $data, callable $onResponse = null ) : boolean
$key string Key
$data string Data
$onResponse callable Callback called when the request complete
return boolean Success
    public function requestByKey($key, $data, $onResponse = null)
    {
        $this->getConnectionByKey($key, function ($conn) use($data, $onResponse) {
            if (!$conn->isConnected()) {
                return;
            }
            $conn->onResponse($onResponse);
            $conn->write($data);
        });
        return true;
    }