mirror of
https://github.com/YGGverse/nex-php.git
synced 2026-04-01 18:25:28 +00:00
Compare commits
No commits in common. "main" and "1.0.0" have entirely different histories.
4 changed files with 10 additions and 38 deletions
15
README.md
15
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# nex-php
|
||||
|
||||
PHP 8 Library for NEX Protocol (see also [nps-php](https://github.com/YGGverse/nps-php))
|
||||
PHP 8 Library for Nex Protocol
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ composer require yggverse/nex
|
|||
|
||||
## Client
|
||||
|
||||
PHP interface for NEX protocol queries
|
||||
PHP interface for Nex protocol queries
|
||||
|
||||
``` php
|
||||
$client = new \Yggverse\Nex\Client;
|
||||
|
|
@ -41,7 +41,7 @@ var_dump(
|
|||
|
||||
## Server
|
||||
|
||||
Build interactive server instance to listen NEX protocol connections!
|
||||
Build interactive server instance to listen Nex protocol connections!
|
||||
|
||||
``` php
|
||||
$server = new \Yggverse\Nex\Server;
|
||||
|
|
@ -73,15 +73,12 @@ $server->start(
|
|||
function (
|
||||
string $request,
|
||||
string $connect
|
||||
): ?string
|
||||
{
|
||||
) {
|
||||
printf(
|
||||
'connection: %s request: %s',
|
||||
$connect,
|
||||
$request
|
||||
);
|
||||
|
||||
return null; // null|string response
|
||||
}
|
||||
);
|
||||
```
|
||||
|
|
@ -91,7 +88,3 @@ $server->start(
|
|||
Stop server instance.
|
||||
|
||||
Same to `Server::setLive(false)`
|
||||
|
||||
## Integrations
|
||||
|
||||
* [next](https://github.com/YGGverse/next) - PHP 8 Server for NEX Protocol
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "yggverse/nex",
|
||||
"description": "PHP 8 Library for Nex Protocol",
|
||||
"keywords": [ "yggverse", "nex", "nex-protocol", "client", "server" ],
|
||||
"keywords": [ "yggverse", "nex", "nex-protocol", "client" ],
|
||||
"homepage": "https://github.com/yggverse/nex-php",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -113,10 +113,7 @@ class Client
|
|||
sprintf(
|
||||
"%s%s\r\n",
|
||||
$this->_path,
|
||||
$this->_query ? sprintf(
|
||||
'?%s',
|
||||
$this->_query
|
||||
) : null
|
||||
$this->_query
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -108,17 +108,14 @@ class Server
|
|||
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN
|
||||
);
|
||||
|
||||
if ($this->_live)
|
||||
{
|
||||
$this->_live = is_resource(
|
||||
$socket
|
||||
);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (!$this->_live)
|
||||
{
|
||||
fclose(
|
||||
$socket
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -148,14 +145,6 @@ class Server
|
|||
$request,
|
||||
$connect
|
||||
);
|
||||
|
||||
if ($response)
|
||||
{
|
||||
fwrite(
|
||||
$incoming,
|
||||
$response
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(
|
||||
|
|
@ -163,13 +152,6 @@ class Server
|
|||
);
|
||||
|
||||
} while ($this->_live);
|
||||
|
||||
if (is_resource($socket))
|
||||
{
|
||||
fclose(
|
||||
$socket
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function stop(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue