R-Type
Public Member Functions | List of all members
RType::Client::UdpClient Class Reference

#include <UdpClient.hpp>

Inheritance diagram for RType::Client::UdpClient:
GameEngine::Network::ACommunication

Public Member Functions

 UdpClient (asio::io_context &IOContext, asio::ip::udp::endpoint &serverEndpoint, SafeQueue< struct RType::Event > &eventQueue)
 
 ~UdpClient ()
 
void handleTransformComponent (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleTextureComponent (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleCollisionComponent (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleControllableComponent (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleTextureState (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleScore (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleEndGame (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleString (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 Handle String. More...
 
void handleDisconnexion (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 Handle Disconnexion. More...
 
void sendDataInformation (std::vector< std::byte > dataInformation, uint8_t packetType)
 Function that will send information to the server. More...
 
void run ()
 Launch the Udp Client. More...
 
void handleData (struct RType::Protocol::HeaderDataPacket &, unsigned short port)
 Handle the data depends of the header. More...
 
- Public Member Functions inherited from GameEngine::Network::ACommunication
 ACommunication (asio::io_context &IOContext, unsigned short port)
 Abstract class that will handle communication. More...
 
virtual ~ACommunication ()
 
template<typename Socket , typename Endpoint >
void sendData (void *data, std::size_t size, uint8_t packetType, Socket &socket, Endpoint &endpoint)
 Set the header to send the value. More...
 
void sendInformation (void *data, std::size_t size, asio::ip::udp::socket &socket, asio::ip::udp::endpoint &endpoint, struct RType::Protocol::HeaderDataPacket &header)
 send the data to endpoint from the socket More...
 
void sendInformation (void *data, std::size_t size, asio::ip::tcp::socket &socket, asio::ip::tcp::endpoint &, struct RType::Protocol::HeaderDataPacket &header)
 send the data to endpoint from the socket More...
 
void handleReceive (const asio::error_code &error, std::size_t recvBytes, struct RType::Protocol::HeaderDataPacket &header)
 handle the header information More...
 
void readHeader ()
 read the header to retrieve informations More...
 

Additional Inherited Members

- Protected Attributes inherited from GameEngine::Network::ACommunication
asio::streambuf _streamBuffer
 
asio::ip::udp::socket _udpSocket
 
asio::streambuf::mutable_buffers_type _buffer
 
struct RType::Protocol::HeaderDataPacket _header
 
asio::ip::udp::endpoint _endpoint
 
std::map< unsigned short, asio::ip::udp::endpoint > _listClient
 

Constructor & Destructor Documentation

◆ UdpClient()

RType::Client::UdpClient::UdpClient ( asio::io_context &  IOContext,
asio::ip::udp::endpoint &  serverEndpoint,
SafeQueue< struct RType::Event > &  eventQueue 
)

◆ ~UdpClient()

RType::Client::UdpClient::~UdpClient ( )

Member Function Documentation

◆ handleCollisionComponent()

void RType::Client::UdpClient::handleCollisionComponent ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleControllableComponent()

void RType::Client::UdpClient::handleControllableComponent ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleData()

void RType::Client::UdpClient::handleData ( struct RType::Protocol::HeaderDataPacket header,
unsigned short  port 
)
virtual

Handle the data depends of the header.

Parameters
errorif asynchronous operation fails, it will be checked
headerthat contain the type of data

Implements GameEngine::Network::ACommunication.

◆ handleDisconnexion()

void RType::Client::UdpClient::handleDisconnexion ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

Handle Disconnexion.

Parameters
headerthat contains the size of the payload

◆ handleEndGame()

void RType::Client::UdpClient::handleEndGame ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleScore()

void RType::Client::UdpClient::handleScore ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleString()

void RType::Client::UdpClient::handleString ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

Handle String.

Parameters
headerthat contains the size of the payload

◆ handleTextureComponent()

void RType::Client::UdpClient::handleTextureComponent ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleTextureState()

void RType::Client::UdpClient::handleTextureState ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleTransformComponent()

void RType::Client::UdpClient::handleTransformComponent ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ run()

void RType::Client::UdpClient::run ( )

Launch the Udp Client.

◆ sendDataInformation()

void RType::Client::UdpClient::sendDataInformation ( std::vector< std::byte >  dataInformation,
uint8_t  packetType 
)

Function that will send information to the server.

Parameters
dataInformationthat contains the information
packetTypecorresponding the type of data

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