Registry.php
RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.
PHP version 5
- Author
- Vasil Rangelov
- Category
- Net
- Copyright
- 2011 Vasil Rangelov
- License
- LGPL License 2.1
- Link
- http://pear2.php.net/PEAR2_Net_RouterOS
- Package
- PEAR2_Net_RouterOS
- Version
- 1.0.0b3
\PEAR2\Net\RouterOS\Registry
Provides functionality for managing the request/response flow. Particularly useful in persistent connections.
- Author
- Vasil Rangelov
- Category
- Net
- License
- LGPL License 2.1
- Link
- http://pear2.php.net/PEAR2_Net_RouterOS
Properties


int $instanceIdSeed = -1
ID to be given to next instance, after incrementing it.
-1
Details- Type
- int


int $requestId = -1
ID of request. Populated at first instance in request.
-1
Details- Type
- int
Methods


__construct(string $uri) : void
Creates a registry.
Name | Type | Description |
---|---|---|
$uri | string | An URI to bind the registry to. |


_add(\PEAR2\Net\RouterOS\Response $response, \PEAR2\Net\RouterOS\type $targetBufferName) : void
Adds a response to a buffer.
Name | Type | Description |
---|---|---|
$response | \PEAR2\Net\RouterOS\Response | The response to add. |
$targetBufferName | \PEAR2\Net\RouterOS\type | The name of the buffer to add the response to. |


_close(string $targetBufferName) : void
Removes a buffer.
Name | Type | Description |
---|---|---|
$targetBufferName | string | The buffer to remove. |


add(\PEAR2\Net\RouterOS\Response $response, string $ownershipTag) : bool
Add a response to the registry.
Name | Type | Description |
---|---|---|
$response | \PEAR2\Net\RouterOS\Response | The response to add. The caller of this function is responsible for ensuring that the ownership tag and the original tag are separated, so that only the original one remains in the response. |
$ownershipTag | string | The ownership tag that the response had. |
Type | Description |
---|---|
bool | TRUE if the request was added to its buffer, FALSE if this instance owns the response, and therefore doesn't need to add the response to its buffer. |


getNextResponse() : \PEAR2\Net\RouterOS\Response | null
Gets the next response from this instance's buffer.
Type | Description |
---|---|
\PEAR2\Net\RouterOS\Response | null | The next response, or NULL if there isn't one. |


getOwnershipTag() : string
Get the ownership tag for this instance.
Type | Description |
---|---|
string | The ownership tag for this registry instance. |


isTaglessModeOwner() : bool
Checks if this instance is the tagless mode owner.
Type | Description |
---|---|
bool | TRUE if this instance is the tagless mode owner, FALSE otherwise. |


parseTag(string $tag) : array
Parses a tag.
Parses a tag to reveal the ownership part of it, and the original tag.
Name | Type | Description |
---|---|---|
$tag | string | The tag (as received) to parse. |
Type | Description |
---|---|
array | An array with the first member being the ownership tag, and the second one being the original tag. |


setTaglessMode(bool $taglessMode) : bool
Sets the "tagless mode" setting.
While in tagless mode, this instance will claim owhership of any responses without a tag. While not in this mode, any requests without a tag will be given to all instances.
Regardless of mode, if the type of the response is Response::TYPE_FATAL, it will be given to all instances.
Name | Type | Description |
---|---|---|
$taglessMode | bool | TRUE to claim tagless ownership, FALSE to release such ownership, if taken. |
Type | Description |
---|---|
bool | TRUE on success, FALSE on failure. |