December 2015
Beginner to intermediate
522 pages
11h 21m
English
Our server is quite useless if we don't have the means of connecting to it and sending messages back and forth. In a separate project, let's create a file named Client_Main.cpp and begin writing the client portion of the code, starting with a packet handler:
void HandlePacket(const PacketID& l_id,
sf::Packet& l_packet, Client* l_client)
{
if ((PacketType)l_id == PacketType::Message){
std::string message;
l_packet >> message;
std::cout << message << std::endl;
} else if ((PacketType)l_id == PacketType::Disconnect){
l_client->Disconnect();
}
}As you can see, it's really quite a simple design when we have a proper support class to fall back on. The client responds to two types of packets: messages and disconnects. In case a message ...
Read now
Unlock full access