\D3strukt0r\VotifierClient\ServerType

NuVotifier

class D3strukt0r\VotifierClient\ServerType\NuVotifier

The Class to access a server which uses the plugin “NuVotifier”.

private property $host

string — The domain or ip to connect to Votifier

private property $port

int — The port which votifier uses on the server

private property $publicKey

string — The public.key which is generated by the plugin.

private property $protocolV2

bool — Use version 2 of the protocol

private property $token

string|null — The token from the config.yml.

public __construct($host, $port, $publicKey[, $protocolV2, $token])

Creates the NuVotifier object.

Parameters:
  • $host (string) – (Required) The domain or ip to connect to Votifier
  • $port (int|null) – (Required) The port which votifier uses on the server
  • $publicKey (string) – (Required) The key which is generated by the plugin. Only needed if using v1!
  • $protocolV2 (bool) – (Optional) Use version 2 of the protocol (Recommended)
  • $token (string|null) – (Optional) To use version 2 protocol the token is needed from the config.yml.
Throws:

\Exception

public getHost() → string

Returns the host.

Returns:string — Returns the host
public getPort() → int

Returns the port.

Returns:int — Returns the port
public getPublicKey() → string

Returns the public key.

Returns:string — Returns the public key
public isProtocolV2() → bool

Checks whether the connection uses the version 2 protocol.

Returns:bool — Returns true, if using the new version of NuVotifier or false otherwise
public verifyConnection($header) → bool

Verifies that the connection is correct.

Parameters:
  • $header (bool|string) – (Required) The header that the plugin usually sends
Returns:

bool — Returns true if connections is available, otherwise false

public preparePackage($vote) → string

Create encrypted package for default Votifier.

Parameters:
  • $vote (\D3strukt0r\VotifierClient\VoteType\VoteInterface) – (Required) The vote package with all the information
Returns:

string — Returns the string to be sent to the server

public preparePackageV2($vote, $challenge) → string

Prepares the vote package to be sent as version 2 protocol package.

Parameters:
  • $vote (\D3strukt0r\VotifierClient\VoteType\VoteInterface) – (Required) The vote package with information
  • $challenge (string) – (Required) The challenge sent by the server
Returns:

string — Returns the string to be sent to the server

public send($connection, $vote)

Sends the vote package to the server.

Parameters:
  • $connection (\D3strukt0r\VotifierClient\ServerConnection) – (Required) The connection type to the plugin
  • $vote (\D3strukt0r\VotifierClient\VoteType\VoteInterface) – (Required) The vote type package
Throws:

\Exception