Protocol
About 1 min
Protocol
Hazaar Application Protocol Class
The Application Protocol is a simple protocol developed to allow communication between parts of the Hazaar framework over the wire or other IO interfaces. It allows common information to be encoded/decoded between endpoints.
Properties
typeCodes
public array $typeCodes
id
private int $id
last_error
private string $last_error
encoded
private bool $encoded
Methods
__construct
public __construct({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$id | int | |
$encoded | bool |
getLastError
Returns the last error message.
public getLastError({Array})
encoded
Returns whether the application protocol is encoded.
public encoded({Array})
check
Checks that a protocol message type is valid and returns it's numeric value.
public check({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | string | If $type is a string, it is checked and if valid then it's numeric value is returned. If $type is |
an integer it will be returned back if valid. If either is not valid then false is returned. |
getType
Get the type code for a given name.
public getType({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$name | string | the name of the protocol |
getTypeName
Returns the name of the type based on the given type ID.
public getTypeName({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | int | the type ID |
encode
Encodes the payload into a string representation.
public encode({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | int | the type of the payload |
$payload | mixed | the payload to be encoded |
decode
Decodes a packet and extracts the payload and time information.
public decode({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$packet | string | the packet to decode |
$payload | mixed | |
$time | int |
error
Sets the last error message and returns false.
private error({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$msg | string | the error message to be set |
Generated by Hazaar API Doc Generator