1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-06-11 00:03:15 +02:00

Create a factory for easy setup.

Update README.md.
This commit is contained in:
Anthony Birkett
2021-05-31 14:53:28 +01:00
parent ca9edb41c3
commit 780ebba6a2
6 changed files with 49 additions and 27 deletions
+3 -4
View File
@@ -2,16 +2,15 @@
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\Socket\SourceSocket;
use xPaw\SourceQuery\SourceQuery;
use xPaw\SourceQuery\SourceQueryFactory;
// For the sake of this example
header('Content-Type: text/plain');
header('X-Content-Type-Options: nosniff');
$query = new SourceQuery(new SourceSocket());
$query = SourceQueryFactory::createSourceQuery();
try {
$query->connect('localhost', 27015, 1);
+3 -4
View File
@@ -2,16 +2,15 @@
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\Socket\SourceSocket;
use xPaw\SourceQuery\SourceQuery;
use xPaw\SourceQuery\SourceQueryFactory;
// For the sake of this example
header('Content-Type: text/plain');
header('X-Content-Type-Options: nosniff');
$query = new SourceQuery(new SourceSocket());
$query = SourceQueryFactory::createSourceQuery();
try {
$query->connect('localhost', 27015, 1);
+5 -6
View File
@@ -2,14 +2,13 @@
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\Socket\SourceSocket;
use xPaw\SourceQuery\SourceQuery;
use xPaw\SourceQuery\SourceQueryFactory;
$timer = microtime(true);
$query = new SourceQuery(new SourceSocket());
$query = SourceQueryFactory::createSourceQuery();
$info = [];
$rules = [];
@@ -17,8 +16,8 @@ $players = [];
$exception = null;
try {
$query->connect('localhost', 27015, 3);
//$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound
$query->connect('localhost', 27015);
//$query->setUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound
$info = $query->getInfo();
$players = $query->getPlayers();