Original Post
I run my server, and the server starts up fine. When the client connects I get this output... Incoming Connection Received static data Found Player Abnormally lost connection Received static Data Found Player Abnormally lost connection and right here the client program crashes. Currently the only thing both the client and the server do in the loop is check for packets. server packet handling Client setup and connection [Edited by - Mr_Fhqwhgads on January 20, 2007 8:11:04 PM]
switch(packetId)
{
case ID_DISCONNECTION_NOTIFICATION:
{ // Player Disconnected
std::cout << "Player Disconnected";
}
case ID_NEW_INCOMING_CONNECTION:
{ // New Connection
CPlayer player = CPlayer( packet->playerId );
playerList.push_back( player );
std::cout << "Incoming Connection - ";
std::cout << packet->playerId.ToString() << "\n";
}
case ID_RECEIVED_STATIC_DATA:
{ // Received static user data
// Make sure client has current version
std::cout << "Received static data\n";
// Search for the correct player
for(std::list<CPlayer>::iterator plIter = playerList.begin(); plIter != playerList.end(); plIter++)
{
// If we found it
if( plIter->getPlayerID() == packet->playerId )
{
std::cout << "Found Player\n";
// Check version
if( ((SClientData*)(networkManager.getNetworkInterface()->GetStaticClientData(packet->playerId))->GetData())->version
!= networkManager.serverData.version)
{
// Send him a message then kick him.
const char *msg = "Invalid Version";
networkManager.getNetworkInterface()->Send( (char*)msg, strlen(msg)+1, HIGH_PRIORITY, RELIABLE, 0, packet->playerId, false);
networkManager.getNetworkInterface()->Kick(packet->playerId);
}
}
}
}
case ID_MODIFIED_PACKET:
{
// Its teh hax!
}
case ID_CONNECTION_LOST:
// Abnormally lost connection
std::cout << "Abnormally lost connection\n";
break;
default:
// Other kind of message
break;
};
networkInterface = RakNetworkFactory::GetRakClientInterface();
networkInterface->InitializeSecurity( 0, 0 );
networkInterface->SetPassword( PASSWORD );
clientData.version.append( VERSION );
clientData.username.append( "Cirdan" );
networkInterface->SetStaticClientData( UNASSIGNED_PLAYER_ID, (char*)&clientData, sizeof(clientData) );
networkInterface->AllowConnectionResponseIPMigration( false );
if( networkInterface->Connect( SERVER_IP, SERVER_PORT, CLIENT_PORT, 0, 30 ) )
{
std::cout << "Client connected";
}
else
{
std::cout << "Connection faild";
}