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
Network(std::string ip = "127.0.0.1", int port = 4242);
Parameters
ip:
The client ipport:
The server port
setInst
Set the _instOut attribute
void setInst(unsigned char inst);
getStreamOut
return the _outStream attribute
Stream &getStreamOut();
send
send the Stream in parameter to the client
void send(const Stream &message);
send
send the _streamOut stream with the _instOut instruction
void send();
read
This method start the clock that read inputs
void read();
startReceive
This method is the clock that read inputs
void startReceive();
getQueueIn
This method return the in packet queue
Queue<Network::Packet> &getQueueIn();
getNextInst
Try to get an instruction from th _streamIn. If it can, it return the instruction and the stream of request.
std::pair<size_t, Stream> getNextInst();
setClosed
Set the attribute _closed
void setClosed(bool closed);
Last updated