Re: Net_GSQ API Question

From: Date: Thu, 22 Apr 2004 10:46:05 +0000
Subject: Re: Net_GSQ API Question
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-28253@lists.php.net to get a copy of this message
Aidan, Aidan Lister wrote:
I'm trying to work on a better API for Net_GameServerQuery. The way it is now: $base = new net_gameserverquery; $server = $base->query(ip, port, game); print $server->ping(); print_r $server->players(); print_r $server->rules(); The problems with this are: If ping fails (because the server is down, not responding, etc) then the other 3 will fail. Testing the first for false, then doing the other 2 isn't very sexy.
How will they fail? If they barf, then you're doing something wrong. If you just return an error code stating that the server is down, then I don't think it's a real issue. One can't rely on a server to be up all the time in a network app.
Some servers allow you to send requests concurrently, i.e. if I send /status/rules/ I'll get both the status, and the rules reply back. Although it's not neccesary to take advantage of this, it's certainly faster. So, what I'm thinking now: // Put ip/port/game into the loading of the class (much like dom_document, if you want to use the re-use the class, you create another instance) $server = new net_gameserverquery(ip, port, game);
Sounds like a reasonable step.
// query print_r $server->query(NET_GAMESERVERQUERY_REQUEST_PING,
                               NET_GAMESERVERQUERY_REQUEST_STATUS,
                               NET_GAMESERVERQUERY_REQUEST_RULES)
Hardly very attractive
I would've thought an array to be a more appropriate argument to the query method than multiple length arguments. Personally I would stick with the seperate methods, as it leaves the API obvious. If someone wants to alter it, then the license allows them to do so. Regards, David

« previous php.pear.dev (#28253) next »