cvs: pear /Net_GameServerQuery GameServerQuery.php

From: Date: Thu, 01 Jul 2004 11:47:30 +0000
Subject: cvs: pear /Net_GameServerQuery GameServerQuery.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-21347@lists.php.net to get a copy of this message
aidan Thu Jul 1 07:47:30 2004 EDT Modified files: /pear/Net_GameServerQuery GameServerQuery.php Log: Moved some things to Config class http://cvs.php.net/diff.php/pear/Net_GameServerQuery/GameServerQuery.php?r1=1.4&r2=1.5&ty=u Index: pear/Net_GameServerQuery/GameServerQuery.php diff -u pear/Net_GameServerQuery/GameServerQuery.php:1.4 pear/Net_GameServerQuery/GameServerQuery.php:1.5 --- pear/Net_GameServerQuery/GameServerQuery.php:1.4 Wed Jun 30 07:38:05 2004 +++ pear/Net_GameServerQuery/GameServerQuery.php Thu Jul 1 07:47:30 2004 @@ -16,7 +16,11 @@ // | Authors: Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: GameServerQuery.php,v 1.4 2004/06/30 11:38:05 aidan Exp $ +// $Id: GameServerQuery.php,v 1.5 2004/07/01 11:47:30 aidan Exp $ + + +require_once 'Config.php'; +require_once 'Socket.php'; /** @@ -25,7 +29,7 @@ * @category Net * @package Net_GameServerQuery * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class Net_GameServerQuery { @@ -57,6 +61,8 @@ */ private $_game; + private $_config; + /** * Constructor @@ -65,14 +71,9 @@ { // Initialise counter $this->_counter = -1; - - // Load the protocol config - require 'Protocols.php'; - $this->_protocol = $protocol; - - // Load the game config - require 'Games.php'; - $this->_game = $game; + + // Load the config class + $this->_config = new Net_GameServerQuery_Config; } @@ -93,7 +94,7 @@ // Build the list of packets to be sent $querylist = explode('|', $query); foreach ($querylist as $query) { - $querypackets[$query] = $this->_getpacket($game, $query); + $querypackets[$query] = $this->_config->getpacket($game, $query); } // Default port @@ -125,33 +126,11 @@ // Timeout in millseconds $timeout = $timeout * 1000; - require_once 'Socket.php'; $socket = new Net_GameServerQuery_Socket; $result = $socket->go($this->_servers, $timeout); return $result; } - - - /** - * Get the packet to be sent to server - * - * This should probably be moved somewhere else, I don't know where. - * - * @return string The packet - * @param string $game The game - * @param string $query The type of query - */ - private function _getpacket ($game, $query) - { - $protocol = $this->_game[$game]; - $packetformat = $this->_protocol[$protocol]['packet']; - $querystring = $this->_protocol[$protocol]['send'][$query]; - - $packet = sprintf($packetformat, $querystring); - - return $packet; - } }

« previous php.pear.cvs (#21347) next »