network::Server

#include <Server.hpp>

Public Functions

Name

void

sendToClient(const Message & message, uint32_t clientID)

void

sendToAll(const Message & message)

uint32_t

getClientIdByIndex(size_t index)

void

start(unsigned short localPort)

Public Functions Documentation

function ~Server

inline ~Server()

Default destructor of the server Class, stopping the ioService & make all the threads join

function hasMessages

static inline bool hasMessages()

Return: true if there are messages

This function allows us to check if the server has received messages

function sendToClient

static inline void sendToClient(
    const Message & message,
    uint32_t clientID
)

Parameters:

  • message The message you want to send

  • clientID The id of the client you want to communicate with

Used to send a message to a client given as parameter

function sendToAll

static inline void sendToAll(
    const Message & message
)

Parameters:

  • message The message you want to send

Used to send a message to every available clients

function getClientCount

static inline size_t getClientCount()

Return: Amount of connected clients

Get the amount of clients that are connected

function getClientIdByIndex

static inline uint32_t getClientIdByIndex(
    size_t index
)

Parameters:

  • index the index for the array

Return: client ID of client n

Get the ID of client from the clients array

function start

static inline void start(
    unsigned short localPort
)

function getOutgoingMessages

static inline LockedQueue< ServerMessage > & getOutgoingMessages()

Getters & Setters of the Server Class

function GetReceivedMessages

static inline LockedQueue< ClientMessage > & GetReceivedMessages()

Updated on 2022-11-13 at 17:21:37 +0100

Last updated