Need PHP usage examples, please. Testing returning nothing

252 views
Skip to first unread message

Zak Jones

unread,
Jul 14, 2015, 2:37:00 AM7/14/15
to steam-c...@googlegroups.com
I've installed via console using composer/packagist. I'm running Laravel 5.1 on an ec2_micro instance. PHP 5.6, Apache  

$master = new MasterServer(MasterServer::GOLDSRC_MASTER_SERVER);
$servers = $master->getServers(MasterServer::REGION_ALL, '\appid\346110', true);
dd($servers);

I get an empty return every time with the above code. With or without filter parameter(s) being used makes no difference. I haven't gotten any queries to work unless I try an ip specific server. The following code works:

$server = new SourceServer($addr = '52.6.51.142', $port = 27015);
$server->getPlayers();

I receive a list of players as I would expect. I'm finding the docs very hard to follow and there are no stackoverflow or other google group examples which have helped me

My goal is to return all available ARK server information

Sebastian Staudt

unread,
Jul 14, 2015, 2:45:22 AM7/14/15
to steam-c...@googlegroups.com
Hi.

I don't know ARK (just had a quick look at the Steam Store page), so I can't say if it's really supported.
As your query succeeds I guess it might work.

The initial problem using the master server is probably that you used the master server for the GoldSrc engine (the old engine that Half-Life 1 and its mods are based on).

To use the Source master server use:

    $master = new MasterServer(MasterServer::SOURCE_MASTER_SERVER);

or 

    $master = SourceServer::getMaster();

PS: I'm sorry there's no real "Getting Started" or "How-to" documentation available. I would be happy for any suggestions or even better pull-request.

Best regards,
    Sebastian

--
You received this message because you are subscribed to the Google Groups "Steam Condenser" group.
To unsubscribe from this group and stop receiving emails from it, send an email to steam-condens...@googlegroups.com.
To post to this group, send email to steam-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/steam-condenser/e895d64e-b5e6-47a9-8292-4af92cc0714c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zak Jones

unread,
Jul 22, 2015, 9:13:13 PM7/22/15
to Steam Condenser, kora...@gmail.com
I had to take a slightly round-the-ass approach which worked for me. I'll try your suggestion soon --

public function __construct($addr = '52.6.51.142', $port = 27015)
{

try {

$this->server = new SourceServer($addr, $port);
$this->info = $this->server->getServerInfo();
$this->id = $this->info['serverId'];

} catch (SteamCondenserException $e) {}

}

public function getAllServers()
{

if(!$servers = Cache::get('allservers'))
{

$servers = $this->server->getMaster()->getServers(MasterServer::REGION_ALL,'\appid\346110', true);

Cache::put('allservers', $servers, 10);

}

return Cache::get('allservers');

}

But, now the issue is that when I try to query individual servers, they don't all respond within even a 5 or 10 second timeout. I can't seem to catch the error so the code will continue??

public function nameAllServers()
{

if($servers = Cache::get('allservers'))
{

$namedservers = [];

foreach($servers as $server)
{

$mstr = new SourceServer($server[0], $server[1]);
$mstr->initialize();

try
{

$info = $mstr->getServerInfo();

echo $info['serverName'].'<br>';

array_push($namedservers, [
'ip' => $server[0],
'port' => $server[1],
'id' => $info['serverId'],
'name' => $info['serverName']
]);

}
catch(TimeoutException $e) {}
catch(SteamCondenserException $e) {}

}

Cache::put('namedservers', $namedservers, 15);

return Cache::get('namedservers');

}

return $this->getAllServers();

}

Always throws the exception. I've even tried error_reporting(0); Sorry it's so disorganized right now. Just largely playing around and learning-- planning to cycle the updates in small batches with refactoring

Thanks,

Zak

Sebastian Staudt

unread,
Jul 23, 2015, 3:36:36 AM7/23/15
to Zak Jones, Steam Condenser
I don’t know what your `Cache` class does, but the solution to your problem seems to be simple.

The exception is thrown by `initialize()`, so you have to include it in your try-catch-block.
On the other hand, you don’t even need to call `initialize` if you only want server information.

Reply all
Reply to author
Forward
0 new messages