mirror of
https://github.com/YGGverse/yggverse.github.io.git
synced 2025-01-30 16:54:26 +00:00
add nps-php 1.3.0 release
This commit is contained in:
parent
deb00f57cb
commit
ce1c3c1aae
118
nps/nps-php/1.3.0.gmi
Normal file
118
nps/nps-php/1.3.0.gmi
Normal file
@ -0,0 +1,118 @@
|
||||
# nps-php 1.3.0
|
||||
|
||||
## New methods
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#serversetwelcome Server::setWelcome
|
||||
|
||||
Define application logic on peer connection established
|
||||
|
||||
``` php
|
||||
$server->setWelcome(
|
||||
function (
|
||||
string $connect
|
||||
): ?string
|
||||
{
|
||||
printf(
|
||||
"connected: %s\n\r",
|
||||
$connect
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
"welcome, %s\n\r",
|
||||
$connect
|
||||
);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#servergetwelcome Server::getWelcome
|
||||
|
||||
Get current Welcome function, null by default
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#serversetpending Server::setPending
|
||||
|
||||
Define application logic on peer make initial request
|
||||
|
||||
``` php
|
||||
$server->setPending(
|
||||
function (
|
||||
string $request,
|
||||
string $connect
|
||||
): ?string
|
||||
{
|
||||
printf(
|
||||
"connection: %s requested: %s",
|
||||
$connect,
|
||||
$request,
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
"received: %s",
|
||||
$request
|
||||
);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#servergetpending Server::getPending
|
||||
|
||||
Get current Pending function, null by default
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#serversethandler Server::setHandler
|
||||
|
||||
Define basic application logic on complete packet received
|
||||
|
||||
* could be also defined as Server::start argument
|
||||
|
||||
``` php
|
||||
$server->setHandler(
|
||||
function (
|
||||
bool $success,
|
||||
string $content,
|
||||
string $request,
|
||||
string $connect
|
||||
): ?string
|
||||
{
|
||||
printf(
|
||||
'connection: %s request: %s',
|
||||
$connect,
|
||||
$request
|
||||
);
|
||||
|
||||
if ($success)
|
||||
{
|
||||
var_dump(
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
return 'thank you!';
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
=> https://github.com/YGGverse/nps-php#servergethandler Server::getHandler
|
||||
|
||||
Get current Handler function, null by default
|
||||
|
||||
## Example
|
||||
|
||||
``` php
|
||||
$server->start();
|
||||
```
|
||||
|
||||
```
|
||||
> nc 127.0.0.1 1915
|
||||
< welcome, 127.0.0.1:38028
|
||||
> test
|
||||
< received: test
|
||||
> 1
|
||||
> 2
|
||||
> 3
|
||||
> .
|
||||
< thank you!
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
=> https://github.com/YGGverse/nps-php/releases/tag/1.3.0 Download nps-php 1.3.0
|
@ -10,6 +10,7 @@ it listen for single dot in line to signal the package ending.
|
||||
|
||||
## Releases
|
||||
|
||||
=> 1.3.0.gmi 2024-04-25 1.3.0
|
||||
=> 1.2.0.gmi 2024-04-25 1.2.0
|
||||
=> 1.1.0.gmi 2024-04-25 1.1.0
|
||||
=> 1.0.0.gmi 2024-04-24 1.0.0
|
Loading…
x
Reference in New Issue
Block a user