R-Type
Public Member Functions | List of all members
RType::Server::UdpServer Class Reference

UdpServer Class that create a UDP server that client can connect to communicate. More...

#include <UdpServer.hpp>

Inheritance diagram for RType::Server::UdpServer:
GameEngine::Network::ACommunication

Public Member Functions

 UdpServer (asio::io_context &IOContext, unsigned short port, SafeQueue< struct RType::Event > &eventQueue)
 
 ~UdpServer ()
 
void handleData (struct RType::Protocol::HeaderDataPacket &header, unsigned short port)
 Handle the data depends of the header. More...
 
void sendInformation (uint8_t packetType, std::vector< std::byte > dataToSend, asio::ip::udp::endpoint &endpoint)
 Function that will send informations to connected clients. More...
 
void handleString (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 Handle String that will be retrieve and push a event. More...
 
void handleConnexion (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 Handle Connexion that will be retrieve and push a event. More...
 
void handleDisconnexion (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 Handle Disconnexion that will be retrieve and push a event. More...
 
void run ()
 Start the UDP Server. More...
 
void handleTextureResponse (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleCollisionResponse (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
void handleInput (struct RType::Protocol::HeaderDataPacket header, unsigned short port)
 
std::map< unsigned short, asio::ip::udp::endpoint > & getListClients ()
 
- 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
 

Detailed Description

UdpServer Class that create a UDP server that client can connect to communicate.

Constructor & Destructor Documentation

◆ UdpServer()

RType::Server::UdpServer::UdpServer ( asio::io_context &  IOContext,
unsigned short  port,
SafeQueue< struct RType::Event > &  eventQueue 
)

◆ ~UdpServer()

RType::Server::UdpServer::~UdpServer ( )

Member Function Documentation

◆ getListClients()

std::map< unsigned short, asio::ip::udp::endpoint > & RType::Server::UdpServer::getListClients ( )

◆ handleCollisionResponse()

void RType::Server::UdpServer::handleCollisionResponse ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleConnexion()

void RType::Server::UdpServer::handleConnexion ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

Handle Connexion that will be retrieve and push a event.

Parameters
headerthat contains the size of the payload

◆ handleData()

void RType::Server::UdpServer::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::Server::UdpServer::handleDisconnexion ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

Handle Disconnexion that will be retrieve and push a event.

Parameters
headerthat contains the size of the payload

◆ handleInput()

void RType::Server::UdpServer::handleInput ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ handleString()

void RType::Server::UdpServer::handleString ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

Handle String that will be retrieve and push a event.

Parameters
headerthat contains the size of the payload

◆ handleTextureResponse()

void RType::Server::UdpServer::handleTextureResponse ( struct RType::Protocol::HeaderDataPacket  header,
unsigned short  port 
)

◆ run()

void RType::Server::UdpServer::run ( )

Start the UDP Server.

◆ sendInformation()

void RType::Server::UdpServer::sendInformation ( uint8_t  packetType,
std::vector< std::byte >  dataToSend,
asio::ip::udp::endpoint &  endpoint 
)

Function that will send informations to connected clients.

Parameters
packetTypethe type of data that will be send
dataToSendthat will be send to clients

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