OpenGSQ PHP

Vcmp extends ProtocolBase
in package

Class Vcmp

The Vcmp class extends the ProtocolBase class and implements the Vice City Multiplayer Protocol.

Table of Contents

Properties

$fullname  : string
$host  : string
$port  : int
$timeout  : int
$requestHeader  : string
$responseHeader  : string

Methods

__construct()  : mixed
Vcmp constructor.
getPlayers()  : array<string|int, Player>
Get the players on the server.
getStatus()  : Status
Get the status of the server.
getIPAddress()  : string
Gets the Internet Protocol (IP) endpoint.
getResponse()  : string
Send a request to the server and get the response.
readNullString()  : string
Reads a null-padded string from the binary data string.
readString()  : string
Read a string from the response.
readUInt16()  : int
Reads an unsigned 16-bit integer from the binary data string.
readUInt32()  : int
Reads an unsigned 32-bit integer from the binary data string.

Properties

$fullname

public string $fullname = 'Vice City Multiplayer Protocol'

The full name of the protocol.

$timeout

public int $timeout

The timeout for the connection in seconds.

$requestHeader

protected string $requestHeader = "VCMP"

The request header for the protocol.

$responseHeader

protected string $responseHeader = "MP04"

The response header for the protocol.

Methods

__construct()

Vcmp constructor.

public __construct(string $host, int $port[, int $timeout = 5 ]) : mixed
Parameters
$host : string

The host of the server.

$port : int

The port of the server.

$timeout : int = 5

The timeout for the request.

getPlayers()

Get the players on the server.

public getPlayers() : array<string|int, Player>
Return values
array<string|int, Player>

An array of Player objects representing the players on the server.

getStatus()

Get the status of the server.

public getStatus() : Status
Return values
Status

The status of the server.

getIPAddress()

Gets the Internet Protocol (IP) endpoint.

protected getIPAddress() : string
Return values
string

The IP address of the host.

getResponse()

Send a request to the server and get the response.

protected getResponse(string $data) : string
Parameters
$data : string

The data to send with the request.

Tags
throws
InvalidPacketException

If the response is not valid.

Return values
string

The response from the server.

readNullString()

Reads a null-padded string from the binary data string.

protected readNullString(string &$data) : string
Parameters
$data : string

The binary data string. This parameter is passed by reference, and the function will modify it by removing the read bytes.

Return values
string

The null-padded string read from the binary data string.

readString()

Read a string from the response.

protected readString(string $response, int &$offset[, int $readOffset = 1 ]) : string
Parameters
$response : string

The response to read from.

$offset : int

The offset to start reading from.

$readOffset : int = 1

The number of bytes to read for the length of the string.

Return values
string

The string read from the response.

readUInt16()

Reads an unsigned 16-bit integer from the binary data string.

protected readUInt16(string &$data) : int
Parameters
$data : string

The binary data string. This parameter is passed by reference, and the function will modify it by removing the read bytes.

Return values
int

The unsigned 16-bit integer read from the binary data string.

readUInt32()

Reads an unsigned 32-bit integer from the binary data string.

protected readUInt32(string &$data) : int
Parameters
$data : string

The binary data string. This parameter is passed by reference, and the function will modify it by removing the read bytes.

Return values
int

The unsigned 32-bit integer read from the binary data string.


        
On this page

Search results