ClientNetwork
void | [send](<https://luck-bird-6c2.notion.site/Code-Documentation-1e1063108a7280eda42ff11b7a653477>) (const IPacket& packet); |
---|---|
deque<std::unique_ptr<IPacket>> | receive () |
std::unique_ptr<IPacket> | [process_packets](<https://luck-bird-6c2.notion.site/Code-Documentation-1e1063108a7280eda42ff11b7a653477>) (PacketType type, vector<char> payload, uint16_t size) |
send()
void send(const IPacket& packet);
packet
: IPacket
being sent over the network to the server. The packet is received through the receive_from_clients()
method on [ServerNetwork](<https://luck-bird-6c2.notion.site/Code-Documentation-1e1063108a7280eda42ff11b7a653477>).
Function to send a packet to the Server.
Example of use:
// Send an ActionPacket created in function ()
ClientNetwork network = new ClientNetwork(io_context, ip, port);
network.send(ActionPacket(ActionType::FORWARD));
// Create packet first
StringPacket packet = StringPacket("Test");
network.send(packet);
receive()
deque<std::unique_ptr<IPacket>> receive();