mirror of
https://github.com/YGGverse/nps-php.git
synced 2025-01-15 17:30:08 +00:00
update readme
This commit is contained in:
parent
d919203b45
commit
6b4c443e56
38
README.md
38
README.md
@ -23,21 +23,53 @@ Build interactive server instance to listen NPS protocol connections!
|
|||||||
$server = new \Yggverse\Nps\Server;
|
$server = new \Yggverse\Nps\Server;
|
||||||
```
|
```
|
||||||
|
|
||||||
Provide optional `host`, `port` and `size` arguments in constructor or use available setters after object initiation.
|
Provide optional `host`, `port`, `size`, `line` and `live` arguments in constructor.\
|
||||||
|
Alternatively, just use available setters documented bellow after object initiation.
|
||||||
|
|
||||||
``` php
|
``` php
|
||||||
$server = new \Yggverse\Nps\Server('127.0.0.1', 1915);
|
$server = new \Yggverse\Nps\Server('127.0.0.1', 1915);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Server::setHost
|
#### Server::setHost
|
||||||
|
|
||||||
|
Bind server host to listen incoming connections, `127.0.0.1` by default
|
||||||
|
|
||||||
#### Server::getHost
|
#### Server::getHost
|
||||||
|
|
||||||
|
Get current server host
|
||||||
|
|
||||||
#### Server::setPort
|
#### Server::setPort
|
||||||
|
|
||||||
|
Bind server port to listen incoming connections, `1915` by default
|
||||||
|
|
||||||
#### Server::getPort
|
#### Server::getPort
|
||||||
|
|
||||||
|
Get current server port
|
||||||
|
|
||||||
#### Server::setSize
|
#### Server::setSize
|
||||||
|
|
||||||
|
Set total content length limit by [mb_strlen](https://www.php.net/manual/en/function.mb-strlen.php), `0` by default (unlimited)
|
||||||
|
|
||||||
#### Server::getSize
|
#### Server::getSize
|
||||||
|
|
||||||
|
Get current content length limit
|
||||||
|
|
||||||
|
#### Server::setLine
|
||||||
|
|
||||||
|
Set packet line limit in bytes passing to [fread](https://www.php.net/manual/en/function.fread.php#length), `1024` by default
|
||||||
|
|
||||||
|
#### Server::getLine
|
||||||
|
|
||||||
|
Get current packet line limit
|
||||||
|
|
||||||
#### Server::setLive
|
#### Server::setLive
|
||||||
|
|
||||||
|
Set server status `true`|`false` to shutdown immediately
|
||||||
|
|
||||||
#### Server::getLive
|
#### Server::getLive
|
||||||
|
|
||||||
|
Get current server status
|
||||||
|
|
||||||
#### Server::start
|
#### Server::start
|
||||||
|
|
||||||
Run server object using this method.
|
Run server object using this method.
|
||||||
@ -47,6 +79,7 @@ Define handler function as the argument to process application logic dependent o
|
|||||||
``` php
|
``` php
|
||||||
$server->start(
|
$server->start(
|
||||||
function (
|
function (
|
||||||
|
bool $success,
|
||||||
string $content,
|
string $content,
|
||||||
string $request,
|
string $request,
|
||||||
string $connect
|
string $connect
|
||||||
@ -57,10 +90,13 @@ $server->start(
|
|||||||
$request
|
$request
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($success)
|
||||||
|
{
|
||||||
var_dump(
|
var_dump(
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user