Skip to content

Commit

Permalink
Corrections and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklul committed Jul 20, 2020
1 parent 1d87a3b commit 5fa54d2
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 104 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Quake 3 Server List Script #
# Quake 3 Server List

Simple library for querying Quake 3 based master servers and it's game servers.

- Version `1.x.x` uses `fsockopen`
- Version `2.x.x` uses `socket_*` functions
- Version `2.x.x` uses `sockets` extension

_For legacy version check [old](https://github.com/jacklul/q3serverlist/tree/old) branch._

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
}
],
"require": {
"php": "^5.5|^7.0"
"php": "^5.5|^7.0",
"ext-sockets": "*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.2"
Expand Down
6 changes: 4 additions & 2 deletions examples/amphp/composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"require": {
"amphp/parallel": "^1.4",
"jacklul/q3serverlist": "^1.0"
"amphp/parallel": "^1.4"
},
"autoload": {
"psr-4": {
"jacklul\\q3serverlist\\": "../../src"
},
"files": ["functions.php"]
}
}
9 changes: 7 additions & 2 deletions examples/amphp/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* and pthreads extension
*
* This is the fastest and most reliable way of scanning
* the masters server in with multiple threads.
* the masters server with multiple threads
*/

use Amp\Parallel\Worker;
Expand All @@ -20,7 +20,12 @@
exit('Thread safety is required' . PHP_EOL);
}

require __DIR__ . '/vendor/autoload.php';
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../vendor/autoload.php')) {
require __DIR__ . '/../../vendor/autoload.php';
}

$start = microtime(true);

// Fetch the server list
Expand Down
6 changes: 4 additions & 2 deletions examples/pthreads/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"require": {
"jacklul/q3serverlist": "^1.0"
"autoload": {
"psr-4": {
"jacklul\\q3serverlist\\": "../../src"
}
}
}
11 changes: 10 additions & 1 deletion examples/pthreads/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@
exit('Thread safety is required' . PHP_EOL);
}

require __DIR__ . '/vendor/autoload.php';
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../vendor/autoload.php')) {
require __DIR__ . '/../../vendor/autoload.php';
}

$start = microtime(true);

class ServerScan extends Thread
{
private $server;
private $connection;
private $print;
public $result;

public function __construct(Server $server, $print = false)
{
$this->server = $server;
$this->connection = $server->getConnection();
$this->print = $print;
}

Expand Down Expand Up @@ -78,6 +85,8 @@ public function run(): void
print $this->server->getAddress() . ':' . $this->server->getPort() . PHP_EOL;
}
}

$this->server->getConnection()->close();
}
}

Expand Down
8 changes: 6 additions & 2 deletions examples/spatie-async/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"require": {
"spatie/async": "^1.4",
"jacklul/q3serverlist": "^1.0"
"spatie/async": "^1.4"
},
"autoload": {
"psr-4": {
"jacklul\\q3serverlist\\": "../../src"
}
}
}
7 changes: 6 additions & 1 deletion examples/spatie-async/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
use jacklul\q3serverlist\Server;
use Spatie\Async\Pool;

require __DIR__ . '/vendor/autoload.php';
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../vendor/autoload.php')) {
require __DIR__ . '/../../vendor/autoload.php';
}

$start = microtime(true);

function scanServer(Server $server, $print = false): ?array
Expand Down
Loading

0 comments on commit 5fa54d2

Please sign in to comment.