Main Page | Class Hierarchy | Class List | Directories | Class Members | Related Pages | Examples

gsQuery Class Reference

Abstract gsQuery base class. More...

Inheritance diagram for gsQuery:

Inheritance graph
List of all members.

Public Member Functions

 gsQuery ($address, $queryport)
 Standard constructor.
 createInstance ($protocol, $address, $port)
 Creates a new gsQuery object that supports the given protocol.
 unserialize ($string)
 Creates an instance out of an previously serialized string.
 unserializeFromURL ($url)
 Retrieves a serialized object via HTTP and deserializes it.
 getSupportedProtocols ()
 Returns all supported protocols / games.
 getGameJoinerURI ()
 Returns a GameJoiner URI.
 getNativeJoinURI ()
 Returns a native join URI.
 query_server ($getPlayers=TRUE, $getRules=TRUE)
 Querys the server.
 sortPlayers ($players, $sortkey='name')
 Sorts the given players.
 htmlize ($string)
 htmlizes the given raw string
 textify ($string)
 converts the raw string to ascii
 serialize ()
 serializes the object as string
 getDebugDumps ($html=FALSE, $dumper=NULL)
 Creates hexdumps out of the debug info.
 _init ()
 This method deletes all fetched data.
 _sendCommand ($address, $port, $command, $timeout=500000)
 sends a command to a server and returns the answer
 _getClassName ()
 returns the class name of the instance
 __sleep ()
 Serialization handler.

Public Attributes

 $version = '$$$SVN_VERSION$$$'
 The version of the gsQuery package.
 $address
 ip or hostname of the server
 $queryport
 port to use for the query
 $online
 status of the server
 $gamename
 the name of the game
 $hostport
 the port you have to connect to enter the game
 $gameversion
 the version of the game
 $servertitle
 The title of the server.
 $mapname
 The name of the map (often corresponds with the filename of the map).
 $maptitle
 A more descriptive name of the map.
 $gametype
 The gametype.
 $numplayers
 current number of players on the server
 $maxplayers
 maximum number of players allowed on the server
 $password
 Wheather the game server is password protected.
 $nextmap
 next map on the server
 $players
 players playing on the server
 $playerkeys
 Hash of available player infos.
 $playerteams
 list of the team names
 $maplist
 a list of all maps in cycle
 $rules
 Hash with all server rules.
 $errstr
 Short errormessage if something goes wrong.
 $debug
 Array with debug infos.

Detailed Description

Abstract gsQuery base class.

Author:
Jeremias Reith (jr@terragate.net)
Version:
Rev
204

The gsQuery package has one class for each protocol or game. This class is abstract but due to the lack of real OO capabilities it cannot be declared as abstract. Use the static method createInstance to create a gsQuery object that supports the specified protocol.

Generic usage:

   // including gsQuery
   include_once('path/to/gsQuery/gsQuery.php');

   // create a gsQuery instance
   $gameserver = gsQuery::createInstance('gameSpy', 'myserver.com', 1234)

   // query the server
   $status = $gameserver->query_server();

   // check for success
   if($status) {
     // process retrieved data
   } else {
     // create an error message
   }
 
Examples:

example_usage.php, and small_example.php.


Constructor & Destructor Documentation

gsQuery::gsQuery address,
queryport
 

Standard constructor.

Parameters:
address address of the server to query
queryport the queryport of the server


Member Function Documentation

gsQuery::__sleep  ) 
 

Serialization handler.

Returns:
array of variable names to serialize

gsQuery::_getClassName  ) 
 

returns the class name of the instance

Returns:
the class name of the instance
Override this for mixed case class names and support for PHP <5

Reimplemented in armyGame, deusEX, gameSpy, gameSpyQ, halo, igi2, openQuery, ut2004, and vietkong.

gsQuery::_init  ) 
 

This method deletes all fetched data.

For internal use only.

This method should be called if an instance is used for multiple querys

gsQuery::_sendCommand address,
port,
command,
timeout = 500000
 

sends a command to a server and returns the answer

For internal use only.

Parameters:
address ip or hostname of the server
port port to connect to
command data to send
timeout how long to wait for data (in seconds)
Returns:
the raw answser

Reimplemented in gameSpy.

gsQuery::createInstance protocol,
address,
port
 

Creates a new gsQuery object that supports the given protocol.

This static method will create an instance of the appropriate subclass for you.

Parameters:
protocol the protocol you need
address the address of the game server
port the queryport of the game server
Returns:
a gsQuery object that supports the specified protocol
Examples:
example_usage.php, and small_example.php.

gsQuery::getDebugDumps html = FALSE,
dumper = NULL
 

Creates hexdumps out of the debug info.

Parameters:
html whether to create an html hexdump
dumper an optional preconfigured HexDumper instance
Returns:
an array with hexdumps for each send command/received result
Pass an HexDumper instance if you want to format the dump yourself. Each element of the result will contain a 2 element array with the hexdump of the send data first and the dump of the received data behind it.

Reimplemented in gameSpy, and hlife.

gsQuery::getGameJoinerURI  ) 
 

Returns a GameJoiner URI.

See also:
http://gamejoiner.terragate.net
The server has to be queried before in some cases (to find out the game port). The client needs GameJoiner to join the game with this URI

Returns:
A GameJoiner URI

Reimplemented in gameSpy, hlife, and ut2004.

gsQuery::getNativeJoinURI  ) 
 

Returns a native join URI.

Some games are registering an URI type to allow easy joining of games

Returns:
a native join URI or false if not implemented for the game

Reimplemented in ut2004.

gsQuery::getSupportedProtocols  ) 
 

Returns all supported protocols / games.

This method is static. There should be no other php files in the gsQuery directory

Returns:
An array with names of the supported protocols

gsQuery::htmlize string  ) 
 

htmlizes the given raw string

Parameters:
string a raw string from the gameserver that might contain special chars
Returns:
a html version of the given string

Reimplemented in openQuery, q2, q3a, savage, and ut2004.

gsQuery::query_server getPlayers = TRUE,
getRules = TRUE
 

Querys the server.

This method is abstract

Parameters:
getPlayers wheather to retrieve player infos
getRules wheather to retrieve rules
Returns:
TRUE on success

Reimplemented in armyGame, d3, deusEX, gameSpy, gameSpyQ, halo, hlife, hlife2, igi2, mohs, nwn, openQuery, q2, q3a, rvnshld, savage, and vietkong.

gsQuery::serialize  ) 
 

serializes the object as string

Returns:
serialized object representation

gsQuery::sortPlayers players,
sortkey = 'name'
 

Sorts the given players.

You can sort by name, score, frags, deaths, honor and time

Parameters:
players players to sort
sortkey sort by the given key
Returns:
sorted player hash

Reimplemented in armyGame, and gameSpyQ.

gsQuery::textify string  ) 
 

converts the raw string to ascii

Parameters:
string a raw string from the gameserver that might contain special chars
Returns:
a plain text version of the given string

Reimplemented in q2.

gsQuery::unserialize string  ) 
 

Creates an instance out of an previously serialized string.

Use this to restore a object that has been previously serialized with serialize

Parameters:
string serialized gsQuery object
Returns:
the deserialized object

gsQuery::unserializeFromURL url  ) 
 

Retrieves a serialized object via HTTP and deserializes it.

Useful if UDP traffic isn't allowed

Parameters:
url the URL of the object
Returns:
the deserialized object
Examples:
example_usage.php.


Member Data Documentation

gsQuery::$debug
 

Array with debug infos.

Stores all the send/received data Format: send data => received data

gsQuery::$online
 

status of the server

TRUE: server online, FALSE: server offline

gsQuery::$password
 

Wheather the game server is password protected.

1: server is password protected
0: server is not password protected
-1: unknown

gsQuery::$playerkeys
 

Hash of available player infos.

There is a key for each player info available (e.g. name, score, ping etc). The value is TRUE if the info is available

gsQuery::$players
 

players playing on the server

See also:
playerkeys
Hash with player ids as key. The containing value will be another hash with the infos of the player. To access a player name use players[$playerid]['name']. Check playerkeys to get the keys available

gsQuery::$rules
 

Hash with all server rules.

key: rulename
value: rulevalue


The documentation for this class was generated from the following file:
Generated on Sat Oct 15 16:51:59 2005 for gsQuery by  doxygen 1.4.4