Static constructor - start processor

@param array $payload
@param Parameters $parameters
@param LoggerInterface $logger

@return mixed
@throws RpcException
@throws Exception
174243
public static function process(array $payload, Parameters $parameters, LoggerInterface $logger) {

        try {

            $processor = new self($payload, $parameters, $logger);

            $return = $processor->run();

        } catch (RpcException $re) {

            throw $re;

        } catch (Exception $e) {

            throw $e;

        }

        return $return;

    }
1096332
public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;
        $this->getClient()->setLogger($logger);
    }
267224
public function setLogger(LoggerInterface $logger):void{
		$this->logger = $logger;
		$this->driver->setLogger($logger);
		$this->query->setLogger($logger);
	}
423442
function start(payload) {
  for (var id in this.callbacks) {
    this.isPending[id] = false;
    this.isHandled[id] = false;
  }
  this.isDispatching = true;
  this.pendingPayload = payload;
}
307217
public function parse($payload)
    {
        if (function_exists('msgpack_unpack')) {
            if ($payload) {
                $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
                    throw new \Exception($errstr);  // @codeCoverageIgnore
                });

                try {
                    $msg = msgpack_unpack(trim($payload));
                    if ( ! $msg) {
                        throw new \Exception('Unknown error');  // @codeCoverageIgnore
                    }
                } catch (\Exception $e) {
                    set_error_handler($prevHandler);
                    throw new ParserException('Failed To Parse MSGPack - ' . $e->getMessage());
                }

                set_error_handler($prevHandler);

                return $msg;
            }
            return [];
        }

        throw new ParserException('Failed To Parse MSGPack - Supporting Library Not Available');  // @codeCoverageIgnore
    }
1333951
public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;
        if (isset($logger)) {
            $this->parser->setLogger($logger);
            $this->nsParser->setLogger($logger);
        }
    }
878755
public function handlePayload(Payload $payload): void
    {
        $app = $this->getClientApplication();

        $this->logger->debug('Handling payload: ' . $payload->getPayload());

        switch ($type = $payload->getType()) {
            case Protocol::TYPE_TEXT:
                if (method_exists($app, 'onData')) {
                    $app->onData((string)$payload, $this);
                }
                return;

            case Protocol::TYPE_BINARY:
                if (method_exists($app, 'onBinaryData')) {
                    $app->onBinaryData((string)$payload, $this);
                } else {
                    $this->close(1003);
                }
                break;

            case Protocol::TYPE_PING:
                $this->logger->info('Ping received', 'notice');
                $this->send($payload->getPayload(), Protocol::TYPE_PONG);
                $this->logger->info('Pong!', 'debug');
                break;

            /**
             * A Pong frame MAY be sent unsolicited.  This serves as a
             * unidirectional heartbeat.  A response to an unsolicited Pong
             * frame is not expected.
             */
            case Protocol::TYPE_PONG:
                $this->logger->info('Received unsolicited pong');
                break;

            case Protocol::TYPE_CLOSE:
                $this->logger->notice('Close frame received');
                $this->close();
                $this->logger->info('Disconnected');
                break;

            default:
                throw new ConnectionException('Unhandled payload type');
        }
    }
428629
public static function createLogger( $channel, array $handlers = array(), array $processors = array() )
    {
        if ( !$handlers )
        {
            $_handler = new StreamHandler( static::$_defaultLog );
            $_handler->setFormatter( new PaddedLineFormatter( null, null, true, true ) );

            $handlers = array($_handler);
        }

        return new Logger( $channel ?: static::DEFAULT_CHANNEL_NAME, $handlers, $processors );
    }
1005791
public function addStartButton(string $payload): self
    {
        $this->isValidString($payload, 1000);

        $this->startButton = [
            'payload' => $payload,
        ];

        return $this;
    }
277540
public function setLogger($logger)
    {
        if ($this->logger !== null && ($this->logger instanceof LoggerInterface) === false) {
            throw new Exception\InvalidArgumentException('$logger must be an instance of \Psr\Log\LoggerInterface or null');
        }

        $this->logger = $logger;
        $this->onConfigChanged();
    }
893405
public static function register(LoggerInterface $logger = null)
    {
        $handler = new static($logger);

        set_error_handler(array($handler, 'handleError'));
        register_shutdown_function(array($handler, 'handleFatalError'));

        set_exception_handler(array($handler, 'handleException'));
    }
35521
private function use_default_processor( $logger ) {

		$processor = $this->processors_registry->find( ProcessorsRegistry::DEFAULT_NAME );
		if ( ! is_callable( $processor ) ) {

			return NULL;
		}

		/**
		 * Filters whether to use the default processor.
		 *
		 * @param bool     $use_default_processor
		 * @param Logger   $logger
		 * @param callable $processor
		 */
		if ( apply_filters( self::FILTER_USE_DEFAULT_PROCESSOR, TRUE, $logger, $processor ) ) {
			return $processor;
		}

		return NULL;
	}
101133
public void startLogging(RequestLogger logger) {
    ResourceServices services = getServices();
    if (services != null)
      services.startLogging(logger);
  }
1108357
public function sendPayload($payload, $callback)
    {
        if (!is_string($payload)) {
            throw new \InvalidArgumentException('Payload must be string.');
        }

        try {
            $res = $this->client->post($this->host, [
                'headers' => [
                    'content-type' => 'application/json'
                ],
                'body' => $payload,
                'timeout' => $this->timeout,
                'connect_timeout' => $this->timeout
            ]);
            /**
             * @var StreamInterface $stream ;
             */
            $stream = $res->getBody();
            $json = json_decode($stream);
            $stream->close();

            if (JSON_ERROR_NONE !== json_last_error()) {
                call_user_func($callback, new InvalidArgumentException('json_decode error: ' . json_last_error_msg()), null);
            }
            if (is_array($json)) {
                // batch results
                $results = [];
                $errors = [];

                foreach ($json as $result) {
                    if (property_exists($result,'result')) {
                        $results[] = $result->result;
                    } else {
                        if (isset($json->error)) {
                            $error = $json->error;
                            $errors[] = new RPCException(mb_ereg_replace('Error: ', '', $error->message), $error->code);
                        } else {
                            $results[] = null;
                        }
                    }
                }
                if (count($errors) > 0) {
                    call_user_func($callback, $errors, $results);
                } else {
                    call_user_func($callback, null, $results);
                }
            } elseif (property_exists($json,'result')) {
                call_user_func($callback, null, $json->result);
            } else {
                if (isset($json->error)) {
                    $error = $json->error;

                    call_user_func($callback, new RPCException(mb_ereg_replace('Error: ', '', $error->message), $error->code), null);
                } else {
                    call_user_func($callback, new RPCException('Something wrong happened.'), null);
                }
            }
        } catch (RequestException $err) {
            call_user_func($callback, $err, null);
        }
    }
39066
public function send($payload, ProtoStream $stream = null)
    {
        $socket = $stream ?: $this->getStream();

        $socket->write($payload);

        return $socket;
    }
393843
@Override
	public void start() throws PacketTransportException
    {
        try
        {
        	NetworkInputChannel inputChannel = 
        		new NetworkInputChannel(initialPacketBufferSize,
        				                new TcpBufferedInputStream(socket.getInputStream(),streamRecvBufferSize));
        	NetworkOutputChannel outputChannel = 
        		new NetworkOutputChannel(initialPacketBufferSize,
        				                 new TcpBufferedOutputStream(socket.getOutputStream(),streamSendBufferSize));
        	
            sender = new TcpPacketSender(this,
            		                     outputChannel,
            		                     listener,
            		                     client ? pingInterval : -1,
            		                     sendQueueMaxSize);
            
            receiver = new TcpPacketReceiver(this,
            								 inputChannel,
            		                         listener,
            		                         pingInterval,
            		                         client ? -1 : maxPacketSize);
            
            senderThread = new Thread(sender,"TcpPacketSender["+(client ? "client" : "server")+"]");
            senderThread.start();
            
            receiverThread = new Thread(receiver,"TcpPacketReceiver["+(client ? "client" : "server")+"]");
            receiverThread.start();
        }
        catch (Exception e)
        {
            log.error("#"+id+" cannot start TCP packet I/O handlers",e);
            throw new PacketTransportException("Cannot start TCP packet I/O handlers : "+e.toString());
        }
    }
182184
private function setLogger($logger)
    {
        $psr = 'Psr\\Log\\LoggerInterface';
        if (!is_a($logger, $psr)) {
            throw new InvalidArgumentException(
                sprintf('Expected an instance of %s', $psr)
            );
        }

        $this->logger = $logger;
    }