Jetpack documentation 1.0.0
Loading...
Searching...
No Matches
Server::Client Class Reference

A class that represents a client connected to the server. More...

#include <ServerClient.hpp>

Public Member Functions

 Client (int socket_fd, struct sockaddr_in client_addr, double start_y_pos)
 Constructor for Client class.
 
 ~Client ()
 Destructor for Client class.
 
 Client (const Client &)
 Copy constructor for Client class.
 
Clientoperator= (const Client &)
 Assignment operator for Client class.
 
const std::string & getNextCommand () const
 Gets the next command to be executed.
 
void setNextCommand (const std::string &nextCommand)
 Sets the next command to be executed.
 
const int & getSocketFd () const
 Gets the socket file descriptor.
 
const struct sockaddr_in & getClientAddr () const
 Gets the client address.
 
const std::string & getPseudo () const
 Gets the pseudo of the client.
 
void setPseudo (const std::string &pseudo)
 Sets the pseudo of the client.
 
const std::array< double, 2 > & getPosition () const
 Gets the position of the client.
 
void setPosition (const std::array< double, 2 > &position)
 Sets the position of the client.
 
const std::size_t & getScore () const
 Gets the score of the client.
 
void setScore (std::size_t score)
 Sets the score of the client.
 
const bool & isAlive () const
 Gets the alive status of the client.
 
void setAlive (bool alive)
 Sets the alive status of the client.
 
const bool & useJetpack () const
 Gets the jetpack status of the client.
 
void setJetpack (bool jetpack)
 Sets the jetpack status of the client.
 
const double & getSpeed () const
 Gets the speed of the client.
 
void setSpeed (double speed)
 Sets the speed of the client.
 
std::vector< std::array< std::size_t, 2 > > & getCoinsList ()
 Gets the list of coins collected by the client.
 

Private Attributes

std::string _next_command
 
const int _socket_fd
 
const struct sockaddr_in _client_addr
 
std::string _pseudo
 
std::array< double, 2 > _position = {0.0, 0.0}
 
std::size_t _score = 0
 
bool _alive = true
 
bool _jetpack = false
 
double _speed = 0.0
 
std::vector< std::array< std::size_t, 2 > > _coins_list
 

Detailed Description

A class that represents a client connected to the server.

Constructor & Destructor Documentation

◆ Client() [1/2]

Client ( int socket_fd,
struct sockaddr_in client_addr,
double start_y_pos )

Constructor for Client class.

Parameters
socket_fdThe socket file descriptor of the client
client_addrThe address of the client
start_y_posThe starting y position of the client

◆ Client() [2/2]

Client ( const Client & client)

Copy constructor for Client class.

Parameters
clientThe Client object to copy from

Member Function Documentation

◆ getClientAddr()

const struct sockaddr_in & getClientAddr ( ) const

Gets the client address.

Returns
The client address

◆ getCoinsList()

std::vector< std::array< std::size_t, 2 > > & getCoinsList ( )

Gets the list of coins collected by the client.

Returns
The list of coins collected by the client

◆ getNextCommand()

const std::string & getNextCommand ( ) const

Gets the next command to be executed.

Returns
The next command to be executed

◆ getPosition()

const std::array< double, 2 > & getPosition ( ) const

Gets the position of the client.

Returns
The position of the client

◆ getPseudo()

const std::string & getPseudo ( ) const

Gets the pseudo of the client.

Returns
The pseudo of the client

◆ getScore()

const std::size_t & getScore ( ) const

Gets the score of the client.

Returns
The score of the client

◆ getSocketFd()

const int & getSocketFd ( ) const

Gets the socket file descriptor.

Returns
The socket file descriptor

◆ getSpeed()

const double & getSpeed ( ) const

Gets the speed of the client.

Returns
The speed of the client

◆ isAlive()

const bool & isAlive ( ) const

Gets the alive status of the client.

Returns
The alive status of the client

◆ operator=()

Server::Client & operator= ( const Client & client)

Assignment operator for Client class.

Parameters
clientThe Client object to assign from
Returns
Reference to the current object

◆ setAlive()

void setAlive ( bool alive)

Sets the alive status of the client.

Parameters
aliveThe alive status of the client

◆ setJetpack()

void setJetpack ( bool jetpack)

Sets the jetpack status of the client.

Parameters
jetpackThe jetpack status of the client

◆ setNextCommand()

void setNextCommand ( const std::string & nextCommand)

Sets the next command to be executed.

Parameters
nextCommandThe next command to be executed

◆ setPosition()

void setPosition ( const std::array< double, 2 > & position)

Sets the position of the client.

Parameters
positionThe position of the client

◆ setPseudo()

void setPseudo ( const std::string & pseudo)

Sets the pseudo of the client.

Parameters
pseudoThe pseudo of the client

◆ setScore()

void setScore ( std::size_t score)

Sets the score of the client.

Parameters
scoreThe score of the client

◆ setSpeed()

void setSpeed ( double speed)

Sets the speed of the client.

Parameters
speedThe speed of the client

◆ useJetpack()

const bool & useJetpack ( ) const

Gets the jetpack status of the client.

Returns
The jetpack status of the client

The documentation for this class was generated from the following files: