Worked out the basic server layout

This commit is contained in:
Kayne Ruse
2013-05-03 00:55:47 +10:00
parent b935fcf1d1
commit f349e59fd3
6 changed files with 105 additions and 4 deletions
+21 -3
View File
@@ -4,11 +4,12 @@
#include "SDL_net/SDL_net.h"
#include <stdexcept>
#include <iostream>
using namespace std;
Server::Server() {
//
running = true;
}
Server::~Server() {
@@ -19,15 +20,32 @@ void Server::Init() {
if (SDLNet_Init()) {
throw(runtime_error("Failed to init SDL_net"));
}
netMgr.Init(100);
}
void Server::Proc() {
bool running = true;
while(running) {
//
HandleInput();
UpdateWorld();
HandleOutput();
}
}
void Server::Quit() {
netMgr.Quit();
SDLNet_Quit();
}
void Server::HandleInput() {
//accept new connections
//accept updates from the clients
}
void Server::UpdateWorld() {
//update internals
}
void Server::HandleOutput() {
//send all information to new connections
//selective updates to existing connectons
}
+8
View File
@@ -1,6 +1,8 @@
#ifndef SERVER_HPP_
#define SERVER_HPP_
#include "tcp_network_manager.hpp"
class Server {
public:
Server();
@@ -9,7 +11,13 @@ public:
void Init();
void Proc();
void Quit();
void HandleInput();
void UpdateWorld();
void HandleOutput();
private:
bool running;
TCPNetworkManager netMgr;
};
#endif
+51
View File
@@ -1,2 +1,53 @@
#include "tcp_network_manager.hpp"
TCPNetworkManager::TCPNetworkManager() {
maxConnections = currentConnections = 0;
}
TCPNetworkManager::~TCPNetworkManager() {
//
}
void TCPNetworkManager::Init(int maxConnections) {
//
}
void TCPNetworkManager::Quit() {
//
}
int TCPNetworkManager::AcceptConnection() {
//
}
int TCPNetworkManager::CheckSockets() {
//
}
int TCPNetworkManager::Send(int index, const void* data, int len) {
//
}
int TCPNetworkManager::SendAll(const void* data, int len) {
//
}
int TCPNetworkManager::OpenSocket(const char* host, int port) {
//
}
TCPsocket TCPNetworkManager::GetSocket(int index) {
//
}
int TCPNetworkManager::CloseSocket(int index) {
//
}
int TCPNetworkManager::GetMaxConnections() {
//
}
int TCPNetworkManager::GetCurrentConnections() {
//
}
+1 -1
View File
@@ -11,7 +11,7 @@ public:
void Init(int maxConnections);
void Quit();
int AcceptConnections();
int AcceptConnection();
int CheckSockets();
int Send(int index, const void* data, int len);