From ce1c3c1aae182d0b292cb4205b065fc6b590a5d2 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 25 Apr 2024 16:50:17 +0300 Subject: [PATCH] add nps-php 1.3.0 release --- nps/nps-php/1.3.0.gmi | 118 ++++++++++++++++++++++++++++++++++++++++++ nps/nps-php/index.gmi | 1 + 2 files changed, 119 insertions(+) create mode 100644 nps/nps-php/1.3.0.gmi diff --git a/nps/nps-php/1.3.0.gmi b/nps/nps-php/1.3.0.gmi new file mode 100644 index 0000000..606122d --- /dev/null +++ b/nps/nps-php/1.3.0.gmi @@ -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 \ No newline at end of file diff --git a/nps/nps-php/index.gmi b/nps/nps-php/index.gmi index 11219bc..a8e0e25 100644 --- a/nps/nps-php/index.gmi +++ b/nps/nps-php/index.gmi @@ -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 \ No newline at end of file