\D3strukt0r\Votifier\Client\Server
NuVotifier¶
-
class
D3strukt0r\Votifier\Client\Server\NuVotifier¶ The Class to access a server which uses the plugin “NuVotifier”.
-
protected property
$socket¶ D3strukt0r\Votifier\Client\Socket— The socket object
-
protected property
$host¶ string — The domain or ip to connect to Votifier
-
protected property
$port¶ int — The port which votifier uses on the server
-
protected property
$publicKey¶ string — The public.key which is generated by the plugin
-
protected property
$protocolV2¶ bool — Use version 2 of the protocol
-
protected property
$token¶ string|null — The token from the config.yml
-
public
getSocket() → Socket¶ Gets the Socket.
Returns: D3strukt0r\Votifier\Client\Socket— Returns a Socket object
-
public
setSocket($socket) → $this¶ Sets the Socket.
Parameters: - $socket (string) – The socket object
Returns: $this — Returns the class itself, for doing multiple things at once
-
public
getHost() → string|null¶ Gets the host.
Returns: string|null — Returns the host
-
public
setHost($host) → $this¶ Sets the host.
Parameters: - $host (string) – The host
Returns: $this — Returns the class itself, for doing multiple things at once
-
public
getPort() → int¶ Gets the port.
Returns: int — Returns the port
-
public
setPort($port) → $this¶ Sets the port.
Parameters: - $port (int) – The port
Returns: $this — Returns the class itself, for doing multiple things at once
-
public
getPublicKey() → string|null¶ Gets the public key.
Returns: string|null — Returns the public key
-
public
setPublicKey($publicKey) → $this¶ Sets the public key.
Parameters: - $publicKey (string) – The public key
Returns: $this — Returns the class itself, for doing multiple things at once
-
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
setProtocolV2($isProtocolV2) → $this¶ Sets whether to use version 2 of the protocol.
Parameters: - $isProtocolV2 (bool) – Whether to use version 2 of the protocol
Returns: $this — Returns the class itself, for doing multiple things at once
-
public
getToken() → string|null¶ Gets the token from the config.yml.
Returns: string|null — Returns The token from the config.yml
-
public
setToken($token) → $this¶ Sets the token from the config.yml.
Parameters: - $token (string|null) – The token from the config.yml
Returns: $this — Returns the class itself, for doing multiple things at once
-
public
verifyConnection()¶ Checks if the server actually belongs to Votifier.
Throws: InvalidArgumentExceptionIf one required parameter wasn’t set
Throws: D3strukt0r\Votifier\Client\Exception\Socket\NoConnectionExceptionIf connection couldn’t be established
Throws: D3strukt0r\Votifier\Client\Exception\Socket\PackageNotReceivedExceptionIf there was an error receiving the package
Throws: D3strukt0r\Votifier\Client\Exception\NotVotifierExceptionIf the server we are connected to is not a valid Votifier server
-
public
sendVote(...$votes)¶ Sends the vote packages to the server.
Parameters: - $votes (\D3strukt0r\Votifier\Client\Vote\VoteInterface) – The vote packages
Throws: InvalidArgumentExceptionIf one required parameter wasn’t set
Throws: D3strukt0r\Votifier\Client\Exception\Socket\NoConnectionExceptionIf connection couldn’t be established
Throws: D3strukt0r\Votifier\Client\Exception\Socket\PackageNotSentExceptionIf there was an error receiving the package
Throws: D3strukt0r\Votifier\Client\Exception\Socket\PackageNotReceivedExceptionIf there was an error sending the package
Throws: D3strukt0r\Votifier\Client\Exception\NotVotifierExceptionIf the server we are connected to is not a valid Votifier server
Throws: D3strukt0r\Votifier\Client\Exception\NuVotifierExceptionGeneral NuVotifier Exception (an unknown exception)
Throws: D3strukt0r\Votifier\Client\Exception\NuVotifierChallengeInvalidExceptionNuVotifier says the challenge was invalid
Throws: D3strukt0r\Votifier\Client\Exception\NuVotifierSignatureInvalidExceptionNuVotifier says the signature was invalid
Throws: D3strukt0r\Votifier\Client\Exception\NuVotifierUnknownServiceExceptionNuVotifier says that the service is unknown (the token doesn’t belong to the service name)
Throws: D3strukt0r\Votifier\Client\Exception\NuVotifierUsernameTooLongExceptionNuVotifier says the username is too long
-
protected
checkRequiredVariablesForPackage($vote)¶ Check that service name, username, address, timestamp and token have been set.
Parameters: - $vote (D3strukt0r\Votifier\Client\Vote\VoteInterface) – The vote to check
Throws: InvalidArgumentExceptionIf one required parameter wasn’t set
-
protected
verifyConnection($header) → bool Verifies that the connection is correct.
Parameters: - $header (string|null) – The header that the plugin usually sends
Returns: bool — Returns true if connections is available, otherwise false
-
protected
preparePackage($vote) → string¶ Create encrypted package for default Votifier.
Parameters: - $vote (\D3strukt0r\Votifier\Client\Vote\VoteInterface) – The vote package with all the information
Returns: string — Returns the string to be sent to the server
-
protected
preparePackageV2($vote, $challenge) → string¶ Prepares the vote package to be sent as version 2 protocol package.
Parameters: - $vote (D3strukt0r\Votifier\Client\Vote\VoteInterface) – The vote package with information
- $challenge (string) – The challenge sent by the server
Returns: string — Returns the string to be sent to the server
-
protected property