The client is registering with the server

This commit is contained in:
Kayne Ruse
2013-06-17 19:53:22 +10:00
parent 69f03cd250
commit fd65fec5f7
8 changed files with 38 additions and 23 deletions
+6 -16
View File
@@ -173,32 +173,22 @@ void ServerApplication::HandleConnection(JoinRequest& request) {
return;
}
//create the containers
ClientData client = { uniqueIndex };
PlayerData player = { uniqueIndex };
uniqueIndex++;
//link the containers
client.playerIndex = player.index;
player.clientIndex = client.index;
//fill the containers
player.handle = request.playerHandle;
player.avatar = request.playerAvatar;
ClientData client = { uniqueIndex++ };
//bind the address
client.channel = netUtil->Bind(&request.meta.address);
//push this information
clients[client.index] = client;
players[player.index] = player;
//send the player their information
Packet p;
p.meta.type = PacketType::JOIN_RESPONSE;
p.joinResponse.playerIndex = player.index;
p.joinResponse.clientIndex = client.index;
//TODO: resource list
netUtil->Send(client.channel, &p, sizeof(Packet));
//send it out to new players
//TODO
//pretty
cout << "New connection" << endl;
cout << "number of clients: " << clients.size() << endl;
}