SourceEngine

Summary
This class extends the base GameQuery class to implement support for the Source Engine query protocol.
Internal method for the gory details of sending request strings and recieving response strings through direct socket communications.
Internal method for constructing request strings that will be sent to the host server.
Internal method for parsing response strings that will be sent to the host server.

GQProtocol_SourceEngine

This class extends the base GameQuery class to implement support for the Source Engine query protocol.  It is indended to be dynamically loaded by the Monitor function defined in the base class.

// include the base class
require_once("GameQuery.php");

// create a monitor instance using this protocol
$monitor = GameQuery::Monitor('SourceEngine', '99.99.99.1:9999', $options );
Summary
Internal method for the gory details of sending request strings and recieving response strings through direct socket communications.
Internal method for constructing request strings that will be sent to the host server.
Internal method for parsing response strings that will be sent to the host server.

Protected Variables

$queriesAssociative array used internally for tracking which types of queries are to be sent.

Reimplemented Methods

_communicate

protected function _communicate($requests =  array())

Internal method for the gory details of sending request strings and recieving response strings through direct socket communications.

For this protocol, it is implemented to query for server info with a simple request-response logic, and to query for player and rule info as a more complex challenge-response logic.

Parameters

$requestsAn array of request strings to be sent to the server.

Returns

An array of strings containing server response data.

_request

protected function _request($options =  NULL)

Internal method for constructing request strings that will be sent to the host server.  By default, queries are sent for details, rules, and players, but each can be disabled using the options array that is passed to the Monitor method.

$monitor = GameQuery::Monitor('MyNewGame', '99.99.99.1:29999', array('players' => 0) );

Parameters

$optionsOptional associative array of directives to control module behavior.  In this protocol class, it indicates which queries to send.

Returns

A string or array of strings containing server request data.

_response

protected function _response($response =  NULL)

Internal method for parsing response strings that will be sent to the host server.

For this protocol, data is broken into three basic sections in the top-level array.

  • server_info
  • player_info
  • team_info

Parameters

$responseUnprocessed response string.

Returns

A nested array structure derived from the server response data.

Internal Methods

protected function _communicate($requests =  array())
Internal method for the gory details of sending request strings and recieving response strings through direct socket communications.
protected function _request($options =  NULL)
Internal method for constructing request strings that will be sent to the host server.
protected function _response($response =  NULL)
Internal method for parsing response strings that will be sent to the host server.