UDPNetworkUtility accepts addresses by value, encapsulated ClientData
I started encapsulating ClientData, and I added the internals for the heartbeat ssytem. However, when I took a look inside UDPNetworkUtility, I realized that I didn't have to pass the IPaddresses by reference anymore. Therefore, I've changed it to accept the addresses by value, and I'm committing that change right away before I finish the heartbeat system. This engine is really shaping up, I think.
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
void ServerApplication::HandlePing(ServerPacket* const argPacket) {
|
||||
ServerPacket newPacket;
|
||||
newPacket.type = SerialPacketType::PONG;
|
||||
network.SendTo(&argPacket->srcAddress, &newPacket);
|
||||
network.SendTo(argPacket->srcAddress, &newPacket);
|
||||
}
|
||||
|
||||
void ServerApplication::HandlePong(ServerPacket* const argPacket) {
|
||||
@@ -46,13 +46,13 @@ void ServerApplication::HandleBroadcastRequest(ServerPacket* const argPacket) {
|
||||
newPacket.playerCount = characterMgr.GetContainer()->size();
|
||||
newPacket.version = NETWORK_VERSION;
|
||||
|
||||
network.SendTo(&argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||
}
|
||||
|
||||
void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
|
||||
//create the new client
|
||||
ClientData newClient;
|
||||
newClient.address = argPacket->srcAddress;
|
||||
newClient.SetAddress(argPacket->srcAddress);
|
||||
|
||||
//load the user account
|
||||
//TODO: handle passwords
|
||||
@@ -69,7 +69,7 @@ void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
|
||||
newPacket.clientIndex = clientIndex;
|
||||
newPacket.accountIndex = accountIndex;
|
||||
|
||||
network.SendTo(&newClient.address, static_cast<SerialPacket*>(&newPacket));
|
||||
network.SendTo(newClient.GetAddress(), static_cast<SerialPacket*>(&newPacket));
|
||||
|
||||
//finished this routine
|
||||
clientMap[clientIndex++] = newClient;
|
||||
@@ -90,7 +90,7 @@ void ServerApplication::HandleDisconnect(ClientPacket* const argPacket) {
|
||||
|
||||
//forward to the specified client
|
||||
network.SendTo(
|
||||
&clientMap[ accountMgr.GetAccount(argPacket->accountIndex)->GetClientIndex() ].address,
|
||||
clientMap[ accountMgr.GetAccount(argPacket->accountIndex)->GetClientIndex() ].GetAddress(),
|
||||
static_cast<SerialPacket*>(argPacket)
|
||||
);
|
||||
|
||||
@@ -148,7 +148,7 @@ void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) {
|
||||
newPacket.region = roomMgr.GetRoom(argPacket->roomIndex)->GetPager()->GetRegion(argPacket->x, argPacket->y);
|
||||
|
||||
//send the content
|
||||
network.SendTo(&argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
@@ -247,7 +247,7 @@ void ServerApplication::HandleSynchronize(ClientPacket* const argPacket) {
|
||||
for (auto& it : *characterMgr.GetContainer()) {
|
||||
newPacket.characterIndex = it.first;
|
||||
CopyCharacterToPacket(&newPacket, it.first);
|
||||
network.SendTo(&client.address, static_cast<SerialPacket*>(&newPacket));
|
||||
network.SendTo(client.GetAddress(), static_cast<SerialPacket*>(&newPacket));
|
||||
}
|
||||
|
||||
//TODO: more in HandleSynchronize()
|
||||
@@ -261,7 +261,7 @@ void ServerApplication::HandleSynchronize(ClientPacket* const argPacket) {
|
||||
|
||||
void ServerApplication::PumpPacket(SerialPacket* const argPacket) {
|
||||
for (auto& it : clientMap) {
|
||||
network.SendTo(&it.second.address, argPacket);
|
||||
network.SendTo(it.second.GetAddress(), argPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user