Network

This class receive all the packets from the server and add them in a queue

Public member functions

Network(std::string ip = "127.0.0.1", int port = 4242);
~Network();
void setInst(unsigned char inst);
Stream &getStreamOut();
void send(const Stream &stream);
void send();
void read();
void startReceive();
Queue<Network::Packet> &getQueueIn();
std::pair<size_t, Stream> getNextInst();
void setClosed(bool closed);

Public attributes

std::thread _ReaderThread;

Private attributes

std::string _ip;
int _port;
asio::io_context _ioContext;
asio::ip::udp::socket _socket;
asio::ip::udp::endpoint _serverEndpoint;
bool _closed;
Stream _streamOut;
unsigned char _instOut;
Stream _streamIn;
Queue<Network::Packet> _queueIn;

Member functions documentation

Constructor

Parameters

  • ip: The client ip

  • port: The server port

setInst

Set the _instOut attribute

getStreamOut

return the _outStream attribute

send

send the Stream in parameter to the client

send

send the _streamOut stream with the _instOut instruction

read

This method start the clock that read inputs

startReceive

This method is the clock that read inputs

getQueueIn

This method return the in packet queue

getNextInst

Try to get an instruction from th _streamIn. If it can, it return the instruction and the stream of request.

setClosed

Set the attribute _closed

Last updated