\D3strukt0r\VotifierClient

ServerConnection

class D3strukt0r\VotifierClient\ServerConnection

The class ServerConnection is used to create a connection to a server.

private property $serverType

\D3strukt0r\VotifierClient\ServerType\ServerTypeInterface — The server type information package

private property $s

resource — The username who wants to receive the rewards

public __construct($serverType)

Creates the ServerConnection object.

Parameters:
  • $serverType (\D3strukt0r\VotifierClient\ServerType\ServerTypeInterface) – (Required) The server type information package to connect to
Throws:

\Exception

public __destruct()

Closes the connection when the object is destroyed.

public send($string) → bool

Sends a string to the server.

Parameters:
  • $string (string) – (Required) The string which should be sent to the server
Returns:

bool — Returns true if string was sent, or false if not

public receive([$length = 64]) → string|null

Reads a string which is being received from the server.

Parameters:
  • $length (int) – (Optional) The length of the requested string
Returns:

string|null — Returns the string that was received from the server