Refactored UDPNetworkUtility, and tied it to SerialPacket

This commit is contained in:
Kayne Ruse
2014-05-28 23:22:00 +10:00
parent de7da81102
commit 7b3bf24e5d
12 changed files with 166 additions and 132 deletions
+3 -7
View File
@@ -22,6 +22,7 @@
#include "server_application.hpp"
#include "sql_utility.hpp"
#include "serial.hpp"
#include <stdexcept>
#include <iostream>
@@ -52,7 +53,7 @@ void ServerApplication::Init(int argc, char** argv) {
if (SDLNet_Init()) {
throw(std::runtime_error("Failed to initialize SDL_net"));
}
network.Open(config.Int("server.port"), PACKET_BUFFER_SIZE);
network.Open(config.Int("server.port"));
std::cout << "Initialized SDL_net" << std::endl;
//Init SQL
@@ -119,12 +120,7 @@ void ServerApplication::Proc() {
SerialPacket packet;
while(running) {
//suck in the waiting packets & process them
while(network.Receive()) {
//get the packet
deserialize(&packet, network.GetInData());
//cache the source address
packet.meta.srcAddress = network.GetInPacket()->address;
//we need to go deeper
while(network.Receive(&packet)) {
HandlePacket(packet);
}
//update the internals