Re: Net_GSQ API Question
| From: | Aidan Lister | Date: | Thu, 22 Apr 2004 12:43:02 +0000 |
| Subject: | Re: Net_GSQ API Question | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28258@lists.php.net to get a copy of this message | ||
"David Grant" <david@grant.org.uk> wrote in message
news:4087A26D.8010004@grant.org.uk...
> 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.
If a connection to a server fails, there is a 1000ms delay in the socket
before it's killed (this is minimum). That happening 4 times is a problem.
>
> > 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.
Yeh, It could be done either way, I think the overloading is nicer.
> Personally I would stick
> with the seperate methods, as it leaves the API obvious.
>
Requests can't be concatenated, this is a big problem if you're querying 10
servers. It would be 4 times slower (with the gamespy protocol) sending each
request seperatly.
> If someone
> wants to alter it, then the license allows them to do so.
Well sure, but we're aiming to release top quality stuff, not quality stuff
that can be improved :)
> Regards,
>
> David