Server
Server
Abstract base class for RPC servers.
class Server extends \Hazaar\ControllerExtends: Hazaar\Controller
Provides core logic for handling remote procedure calls (RPC), method registration, and protocol encoder management. Subclasses must implement specific RPC methods and register protocol encoders for supported content types.
Properties
registeredMethods
protected array $registeredMethodsType: array
encoders
private array $encodersType: array
Methods
__construct
Constructs a new RPC server instance and registers public methods and trait initializers.
public __construct(Request $request): voidParameters
| Parameter | Type | Description |
|---|---|---|
$request | Hazaar\Application\Request | the incoming application request |
__toString
Returns the class name of the RPC server instance.
public __toString(): stringReturns: string
handle
Handles an incoming RPC request and returns the encoded response.
public handle(): ResponseReturns: Hazaar\Controller\Response
Validates encoders and registered methods, parses the request, invokes the target method, and encodes the result or error.
registerMethod
Registers a public method for RPC invocation.
public registerMethod(\ReflectionMethod $reflectionMethod): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionMethod | ReflectionMethod | the method to register |
getEncoder
Retrieves the encoder instance for the specified content type.
public getEncoder(?string $contentType): EncoderReturns: Hazaar\RPC\Interface\Encoder
Parameters
| Parameter | Type | Description |
|---|---|---|
$contentType | string | the content type for which to retrieve the encoder |
registerEncoder
Registers an encoder for a specific content type.
protected registerEncoder(string $contentType, Encoder $encoder): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$contentType | string | the content type to associate with the encoder |
$encoder | Hazaar\RPC\Interface\Encoder | the encoder instance to register |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000