GL - merge with new serverAPI

This commit is contained in:
lindaandersson 2014-01-30 10:57:44 +01:00
commit a249e7ede9
22 changed files with 244 additions and 113 deletions

View File

View File

@ -1,2 +0,0 @@
port 15151
clients 200

View File

@ -1,4 +0,0 @@
ServerInit ..\Settings\ServerInit.ini
More a
more b
more c

View File

@ -39,10 +39,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameP
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
@ -257,18 +259,18 @@ Global
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.ActiveCfg = Debug|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.Build.0 = Debug|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.ActiveCfg = Debug|x64
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.Build.0 = Debug|x64
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.Build.0 = Release|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.ActiveCfg = Release|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32
@ -281,6 +283,18 @@ Global
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.Build.0 = Release|Win32
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.ActiveCfg = Release|x64
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.Build.0 = Release|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -295,7 +309,7 @@ Global
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
EndGlobalSection
EndGlobal

View File

@ -88,18 +88,15 @@ struct GameRecieverObject :public Oyster::Network::NetworkClient
case protocol_Gameplay_ObjectPosition:
{
Client::GameClientState::ObjPos* protocolData = new Client::GameClientState::ObjPos;
protocolData->object_ID = p[1].value.netInt;
Client::GameClientState::ObjPos protocolData;
protocolData.object_ID = p[1].value.netInt;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+2].value.netFloat;
protocolData.worldPos[i] = p[i+2].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
((Client::GameState*)gameClientState)->Protocol(&protocolData);
}
break;

View File

@ -85,7 +85,7 @@ bool GameState::LoadModels(std::wstring mapFile)
scale.v[1].y = 8;
scale.v[2].z = 8;
modelData.world = scale; //modelData.world * translate
modelData.modelPath = L"ball.dan";
modelData.modelPath = L"..\\Content\\Models\\ball.dan";
modelData.id = 0;
obj = new C_Player();
@ -96,7 +96,7 @@ bool GameState::LoadModels(std::wstring mapFile)
modelData.world = Oyster::Math3D::Float4x4::identity;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0));
modelData.world = modelData.world * translate;
modelData.modelPath = L"box.dan";
modelData.modelPath = L"..\\Content\\Models\\box.dan";
modelData.id = 1;
obj = new C_Player();
@ -104,7 +104,6 @@ bool GameState::LoadModels(std::wstring mapFile)
privData->object[privData->object.size() -1 ]->Init(modelData);
modelData.world = Oyster::Math3D::Float4x4::identity;
// add player model
modelData.world = Oyster::Math3D::Float4x4::identity;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0, 15, 0));
@ -199,8 +198,6 @@ bool GameState::Release()
privData->object[i] = NULL;
}
delete this->camera;
delete privData;
privData = NULL;
return true;

View File

@ -19,12 +19,17 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
WindowShell::CreateConsoleWindow();
DanBias::GameServerAPI::GameInitDesc desc;
DanBias::GameServerAPI::ServerInitDesc desc;
desc.listenPort = 15151;
if(DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
if(DanBias::GameServerAPI::ServerInitiate(desc) == DanBias::DanBiasServerReturn_Sucess)
{
DanBias::GameServerAPI::Start();
DanBias::GameServerAPI::Terminate();
DanBias::GameServerAPI::ServerStart();
while (!(GetAsyncKeyState(0x51))) //Q for exit
{
DanBias::GameServerAPI::ServerUpdate();
Sleep(1);
}
DanBias::GameServerAPI::ServerStop();
}
return cmdShow;
}

View File

@ -93,6 +93,7 @@ void Game::CreateTeam()
bool Game::NewFrame()
{
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->BeginFrame();
@ -126,17 +127,7 @@ bool Game::NewFrame()
{
if(this->players[i]->player) this->players[i]->player->EndFrame();
}
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->BeginFrame();
}
API::Instance().Update();
for (unsigned int i = 0; i < this->players.Size(); i++)
{
if(this->players[i]->player) this->players[i]->player->EndFrame();
}
//gameInstance.onMoveFnc(this->level);
return true;

View File

@ -27,7 +27,8 @@ Game::PlayerData::~PlayerData()
delete this->player;
}
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement){
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
{
this->player->Move(movement);
}
void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage)

View File

@ -14,6 +14,7 @@
namespace GameLogic
{
/*
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
{
char* mapName;
@ -42,7 +43,7 @@ namespace GameLogic
private:
Oyster::Network::CustomNetProtocol protocol;
};
*/
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
{
short gameId;

View File

@ -20,14 +20,16 @@ namespace DanBias
void Release();
void Update();
operator bool();
void SetGameDesc(const GameSession::GameDescription& desc);
void GetGameDesc(GameSession::GameDescription& desc);
bool StartGameSession();
private:
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
//void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
void LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
@ -42,7 +44,8 @@ namespace DanBias
private:
Utility::WinTimer timer;
float refreshFrequency;
GameSession* gameSession;
GameSession gameSession;
GameSession::GameDescription description;
};
}//End namespace DanBias
#endif // !DANBIASGAME_GAMELOBBY_H

View File

@ -28,17 +28,39 @@ namespace DanBias
class DANBIAS_SERVER_DLL GameServerAPI
{
public:
struct GameInitDesc
struct ServerInitDesc
{
char* serverName;
int listenPort;
bool threaded;
ServerInitDesc()
: serverName("Game Server")
, listenPort(15151)
{};
};
struct GameServerInfo
{
unsigned int listenPort; // If set to 0, the default port 15151 will be used
const char *serverIp; // This cant be mofidfied..
};
public:
static DanBiasServerReturn Create(const GameInitDesc& desc);
static void Start();
static void Stop();
static void Terminate();
static DanBiasServerReturn ServerInitiate(const ServerInitDesc& desc);
static void ServerStart();
static void ServerStop();
static void ServerUpdate();
static GameServerInfo ServerGetInfo();
static void GameSetMapId(const int& val);
static void GameSetMaxClients(const int& val);
static void GameSetGameMode(const int& val);
static void GameSetGameTime(const int& val);
static int GameGetMapId();
static int GameGetMaxClients();
static int GameGetGameMode();
static int GameGetGameTime();
static const char* GameGetGameName();
static bool GameStart();
};//End class DanBiasServer
}//End Extern "C"

View File

@ -31,7 +31,11 @@ namespace DanBias
*/
struct GameDescription
{
std::wstring mapName;
int mapNumber;
int maxClients;
int gameMode;
int gameTime;
std::string gameName;
Oyster::Network::NetworkSession* owner;
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
};
@ -83,6 +87,9 @@ namespace DanBias
void General_Status ( GameLogic::Protocol_General_Status& p, DanBias::GameClient* c );
void General_Text ( GameLogic::Protocol_General_Text& p, DanBias::GameClient* c );
//Callback method recieving from gamelogic
static void ObjectMove(GameLogic::IObjectData* movedObject);
//Private member variables
private:
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
@ -93,10 +100,10 @@ namespace DanBias
bool isCreated;
bool isRunning;
Utility::WinTimer timer;
GameDescription description;
//Callback method recieving from gamelogic
static void ObjectMove(GameLogic::IObjectData* movedObject);
//TODO: Remove this uggly hax
static GameSession* gameSession;
};//End GameSession
}//End namespace DanBias

View File

@ -25,14 +25,27 @@ namespace DanBias
void GameLobby::Update()
{
if(GetAsyncKeyState(VK_DOWN))
if(GetAsyncKeyState(VK_DOWN)) //TODO: Dont forget to remove this...
this->Send(*GameLogic::Protocol_General_Status().GetProtocol());
this->ProcessClients();
}
GameLobby::operator bool()
void GameLobby::SetGameDesc(const GameSession::GameDescription& desc)
{
return true;
this->description = desc;
}
void GameLobby::GetGameDesc(GameSession::GameDescription& desc)
{
desc = this->description;
}
bool GameLobby::StartGameSession()
{
if(this->gameSession.Create(this->description))
{
this->gameSession.Run();
return true;
}
return false;
}
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)

View File

@ -13,8 +13,8 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
break;
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
break;
case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
break;
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
//break;
case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
break;
case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
@ -54,10 +54,10 @@ void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network
{
printf(p.text.c_str());
}
void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
{
}
//void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
//{
//
//}
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
{

View File

@ -16,7 +16,7 @@
#include <WindowShell.h>
#include <Utilities.h>
#include <WinTimer.h>
#include <Thread\OysterThread.h>
#include <thread>
using namespace DanBias;
using namespace Oyster::Network;
@ -28,37 +28,37 @@ namespace
GameLobby lobby;
NetworkServer server;
WinTimer timer;
GameServerAPI instance;
//typedef void(*WorkerThreadFnc)(GameServerAPI*);
}
DanBiasServerReturn GameServerAPI::Create(const GameInitDesc& desc)
DanBiasServerReturn GameServerAPI::ServerInitiate(const ServerInitDesc& desc)
{
if(server.Init(desc.listenPort, &lobby) == NetworkServer::ServerReturnCode_Error)
{
return DanBiasServerReturn_Error;
}
GameSession::GameDescription d;
lobby.GetGameDesc(d);
d.gameName.assign(desc.serverName);
lobby.SetGameDesc(d);
std::printf("Server created!\t-\t%s: [%i]\n\n", server.GetLanAddress().c_str(), desc.listenPort);
return DanBiasServerReturn_Sucess;
}
void GameServerAPI::Start()
void GameServerAPI::ServerStart()
{
timer.reset();
server.Start();
timer.reset();
while (true)
{
server.ProcessConnectedClients();
lobby.Update();
if(GetAsyncKeyState(0x51)) //Q for exit
break;
}
}
void GameServerAPI::ServerStop()
{
lobby.Release();
server.Shutdown();
double total = timer.getElapsedSeconds();
int time = (int)total;
@ -72,23 +72,87 @@ void GameServerAPI::Start()
printf( "Server has been running for: %i:%i:%i - [hh:mm:ss] \n\n", hour, min, sec );
printf( "Terminating in : ");
for (int i = 0; i < 4; i++)
for (int i = 0; i < 3; i++)
{
printf( "%i ", 3-i );
Sleep(1000);
}
printf( "\nServer terminated!" );
}
void GameServerAPI::Stop()
void GameServerAPI::ServerUpdate()
{
server.Stop();
lobby.ProcessClients();
}
void GameServerAPI::Terminate()
{
lobby.Release();
server.Shutdown();
printf( "Server terminated!" );
server.Update();
lobby.Update();
}
GameServerAPI::GameServerInfo GameServerAPI::ServerGetInfo()
{
GameServerAPI::GameServerInfo i;
i.serverIp = server.GetLanAddress().c_str();
i.listenPort = server.GetPort();
return i;
}
void GameServerAPI::GameSetMapId(const int& val)
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
d.mapNumber = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetMaxClients(const int& val)
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
d.maxClients = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameMode(const int& val)
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
d.gameMode = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameTime(const int& val)
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
d.gameTime = val;
lobby.SetGameDesc(d);
}
int GameServerAPI::GameGetMapId()
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
return d.mapNumber;
}
int GameServerAPI::GameGetMaxClients()
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
return d.maxClients;
}
int GameServerAPI::GameGetGameMode()
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
return d.gameMode;
}
int GameServerAPI::GameGetGameTime()
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
return d.gameTime;
}
const char* GameServerAPI::GameGetGameName()
{
GameSession::GameDescription d;
lobby.GetGameDesc(d);
return d.gameName.c_str();
}
bool GameServerAPI::GameStart()
{
return lobby.StartGameSession();
}

View File

@ -19,12 +19,17 @@ using namespace GameLogic;
namespace DanBias
{
GameSession* GameSession::gameSession = nullptr;
GameSession::GameSession()
:gameInstance(GameAPI::Instance())
{
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
this->gameSession = this;
memset(&this->description, 0, sizeof(GameDescription));
}
GameSession::~GameSession()
@ -39,10 +44,10 @@ namespace DanBias
bool GameSession::Create(GameDescription& desc)
{
this->description = desc;
/* Do some error checking */
if(desc.clients.Size() == 0) return false;
if(!desc.owner) return false;
if(!desc.mapName.size()) return false;
if(this->isCreated) return false;
/* standard initialization of some data */

View File

@ -11,13 +11,19 @@
void ServerFnc()
{
DanBias::GameServerAPI::GameInitDesc desc;
DanBias::GameServerAPI::ServerInitDesc desc;
desc.listenPort = 15151;
if( DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
if(DanBias::GameServerAPI::ServerInitiate(desc) == DanBias::DanBiasServerReturn_Sucess)
{
DanBias::GameServerAPI::Start();
DanBias::GameServerAPI::Terminate();
DanBias::GameServerAPI::ServerStart();
while (!(GetAsyncKeyState(0x51))) //Q for exit
{
DanBias::GameServerAPI::ServerUpdate();
Sleep(1);
}
DanBias::GameServerAPI::ServerStop();
}
Sleep(100);
}
void ClientFnc()

View File

@ -111,7 +111,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;GameServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -127,7 +127,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;GameServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -147,7 +147,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;GameServer_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -167,7 +167,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;GameServer_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -296,7 +296,9 @@ OYSTER_THREAD_ERROR OysterThread::SetWorker(ThreadFnc worker)
}
OYSTER_THREAD_ERROR OysterThread::Terminate()
{
return this->privateData->Terminate();
if(this->privateData)
return this->privateData->Terminate();
return OYSTER_THREAD_ERROR_SUCCESS;
}
OYSTER_THREAD_ERROR OysterThread::Wait()
{

View File

@ -224,7 +224,7 @@ void NetworkServer::Shutdown()
this->privateData->isReleased = true;
}
int NetworkServer::ProcessConnectedClients()
int NetworkServer::Update()
{
int c = 0;
while(!this->privateData->clientQueue.IsEmpty())
@ -282,6 +282,10 @@ std::string NetworkServer::GetLanAddress()
szLocalIP = buff;
return szLocalIP;
}
int NetworkServer::GetPort()
{
return this->privateData->port;
}

View File

@ -46,6 +46,10 @@ namespace Oyster
*/
ServerReturnCode Start();
/** Parses asynchronous connected clients.
*/
int Update();
/**
*
*/
@ -55,10 +59,6 @@ namespace Oyster
*/
void Shutdown();
/** Parses asynchronous connected clients.
*/
int ProcessConnectedClients();
/** Set the main session connected clients will enter when connected to server.
* @param mainSession The session to connect as main server session.
*/
@ -84,6 +84,11 @@ namespace Oyster
*/
std::string GetLanAddress();
/**
*
*/
int NetworkServer::GetPort();
private:
struct PrivateData;
PrivateData* privateData;