in CppServerAndClient/Server/Server.cpp [21:53]
void AcceptNewPlayerConnection(int server_fd, int addrlen, sockaddr_in address, Server *server)
{
int new_socket, valread;
char buffer[1024] = {0};
std::string accepted = "Your connection was accepted and token valid";
std::string notaccepted = "Your token is invalid";
if ((new_socket = accept(server_fd, (struct sockaddr *)&address,
(socklen_t*)&addrlen))<0)
{
std::cout << "Accepting new connection failed\n";
return;
}
// We read just one message from the client with blocking I/O
// For an actual game server you will want to use Boost.Asio or other asynchronous higher level library for the socket communication
valread = read( new_socket , buffer, 1024);
std::cout << buffer << std::endl;
// Try to accept the player session ID through GameLift and inform the client of the result
// You could use this information to drop any clients that are not authorized to join this session
bool success = server->AcceptPlayerSession(buffer);
if(success)
{
send(new_socket , accepted.c_str() , strlen(accepted.c_str()) , 0 );
std::cout << "Accepted player session token\n";
}
else
{
send(new_socket , notaccepted.c_str() , strlen(notaccepted.c_str()) , 0 );
std::cout << "Didn't accept player session token\n";
}
}