cvs: pear /Net_GameServerQuery GameServerQuery.php

From: Date: Thu, 02 Sep 2004 08:57:58 +0000
Subject: cvs: pear /Net_GameServerQuery GameServerQuery.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-23576@lists.php.net to get a copy of this message
aidan Thu Sep 2 04:57:58 2004 EDT Modified files: /pear/Net_GameServerQuery GameServerQuery.php Log: Reorganised class structure http://cvs.php.net/diff.php/pear/Net_GameServerQuery/GameServerQuery.php?r1=1.42&r2=1.43&ty=u Index: pear/Net_GameServerQuery/GameServerQuery.php diff -u pear/Net_GameServerQuery/GameServerQuery.php:1.42 pear/Net_GameServerQuery/GameServerQuery.php:1.43 --- pear/Net_GameServerQuery/GameServerQuery.php:1.42 Sat Aug 28 12:48:46 2004 +++ pear/Net_GameServerQuery/GameServerQuery.php Thu Sep 2 04:57:58 2004 @@ -16,7 +16,7 @@ // | Tom Buskens <ortega@php.net> | // +----------------------------------------------------------------------+ // -// $Id: GameServerQuery.php,v 1.42 2004/08/28 16:48:46 aidan Exp $ +// $Id: GameServerQuery.php,v 1.43 2004/09/02 08:57:58 aidan Exp $ require_once 'GameServerQuery\Config.php'; @@ -30,7 +30,7 @@ * @category Net * @package Net_GameServerQuery * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.42 $ + * @version $Revision: 1.43 $ */ class Net_GameServerQuery { @@ -163,67 +163,7 @@ endswitch; } - - /** - * Validate and process the query list - * - * FIXME - */ - private function _getQueryList($query) - { - $querylist = explode('|', $query); - - // Validate each query - foreach ($querylist as $query) { - if ($query != 'status' && - $query != 'players' && - $query != 'rules') { - - throw new Exception ('Invalid Query'); - } - } - - return $querylist; - } - - - /** - * Map data to the master, communication and processing arrays - * - * FIXME - */ - private function _mapArray ($querylist, $protocol, $game, $addr, $port) - { - foreach ($querylist as $query) { - ++$this->_socketcount; - - // Master list - $this->_serverlist[$this->_socketcount] = array( - 'servid' => $this->_counter, - 'query' => $query - ); - - // Get packet info - list($packet_name, $packet) = $this->_config->packet($protocol, $query); - - // Data sent to communications class - $this->_commlist[$this->_socketcount] = array( - 'addr' => $addr, - 'port' => $port, - 'packet' => $packet - ); - - // Data sent the processing class - $this->_processlist[$this->_socketcount] = array( - 'protocol' => $protocol, - 'game' => $game, - 'query' => $query, - 'packetname' => $packet_name, - ); - } - } - - + /** * Add a server * @@ -253,7 +193,7 @@ $protocol = $this->_config->protocol($game); // Get list of queries to be sent - $querylist = $this->_getQueryList($query); + $querylist = $this->_getQueryFlags($query); // Map arrays $this->_mapArray($querylist, $protocol, $game, $addr, $port); @@ -316,6 +256,72 @@ // Return return $newresult; + } + + + /** + * Validate and process the query flags + * + * @param string $query A pipe delimited list of query flags + */ + private function _getQueryFlags($query) + { + $queryflags = explode('|', $query); + + // Validate each query + foreach ($queryflags as $flag) { + if ($flag != 'status' && + $flag != 'players' && + $flag != 'rules') { + + throw new Exception ('Invalid Query Flag'); + } + } + + return $queryflags; + } + + + /** + * Map data to the master, communication and processing arrays + * + * @param string $queryflags Query flags + * @param string $protocol Protocol + * @param string $game The game + * @param string $addr The address + * @param string $port The port + */ + private function _mapArray ($queryflags, $protocol, $game, $addr, $port) + { + // We loop through each of the query flags + // because each flag gets its own socket + foreach ($queryflags as $flag) { + ++$this->_socketcount; + + // Master list + $this->_serverlist[$this->_socketcount] = array( + 'servid' => $this->_counter, + 'query' => $flag + ); + + // Get packet info + list($packet_name, $packet) = $this->_config->packet($protocol, $flag); + + // Data sent to communications class + $this->_commlist[$this->_socketcount] = array( + 'addr' => $addr, + 'port' => $port, + 'packet' => $packet + ); + + // Data sent the processing class + $this->_processlist[$this->_socketcount] = array( + 'protocol' => $protocol, + 'game' => $game, + 'query' => $flag, + 'packetname' => $packet_name, + ); + } } }

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