GameSpy2

Summary
This class extends the base GameQuery class to implement support for the GameSpy 2 query protocol.
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.
Internal method that, given a byte array, gets concurrent name-value pairs, null-terminated, until an empty pair is reached.
Internal method that, given a byte array, gets a series of null-terminated names, and repeated sets of corresponding null-terminated values.

GQProtocol_GameSpy2

This class extends the base GameQuery class to implement support for the GameSpy 2 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('GameSpy2', '99.99.99.1:9999', $options );
Summary
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.
Internal method that, given a byte array, gets concurrent name-value pairs, null-terminated, until an empty pair is reached.
Internal method that, given a byte array, gets a series of null-terminated names, and repeated sets of corresponding null-terminated values.

Reimplemented Methods

_request

protected function _request($options =  NULL)

Internal method for constructing request strings that will be sent to the host server.  Note that this protocol takes no options.

Parameters

$optionsOptional associative array of directives to control module behavior.  (Not used)

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

_concurrent_fields

private function _concurrent_fields(&$rsp_string =  array(),
$field_type =  '')

Internal method that, given a byte array, gets concurrent name-value pairs, null-terminated, until an empty pair is reached.  This is used to parse server info for the Gamespy 2 protocol.

Parameters

$rsp_stringResponse string as an array of individual bytes.
$field_typeSection key as string.

Returns

A nested array structure of the processed name-value pairs

_nonconcurrent_fields

private function _nonconcurrent_fields(&$rsp_string =  array(),
$field_type =  '')

Internal method that, given a byte array, gets a series of null-terminated names, and repeated sets of corresponding null-terminated values.  This is used to parse player and team info for the Gamespy 2 protocol.

Parameters

$rsp_stringResponse string as an array of individual bytes.
$field_typeSection key as string.

Returns

A nested array structure of the processed name-value pairs

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.
private function _concurrent_fields(&$rsp_string =  array(),
$field_type =  '')
Internal method that, given a byte array, gets concurrent name-value pairs, null-terminated, until an empty pair is reached.
private function _nonconcurrent_fields(&$rsp_string =  array(),
$field_type =  '')
Internal method that, given a byte array, gets a series of null-terminated names, and repeated sets of corresponding null-terminated values.