Browse Source

add nps-php 1.3.0 release

main
yggverse 8 months ago
parent
commit
ce1c3c1aae
  1. 118
      nps/nps-php/1.3.0.gmi
  2. 1
      nps/nps-php/index.gmi

118
nps/nps-php/1.3.0.gmi

@ -0,0 +1,118 @@ @@ -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

1
nps/nps-php/index.gmi

@ -10,6 +10,7 @@ it listen for single dot in line to signal the package ending. @@ -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…
Cancel
Save