Server poking

This commit is contained in:
Dander7BD 2014-02-14 17:12:38 +01:00
parent 2de045524a
commit 2dde8547b7
9 changed files with 77 additions and 58 deletions

View File

@ -120,14 +120,14 @@ void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::Clie
{
switch(ID)
{
case protocol_Lobby_Create: break; /** @todo TODO: implement */
case protocol_Lobby_Start: break; /** @todo TODO: implement */
case protocol_Lobby_Join: break; /** @todo TODO: implement */
case protocol_Lobby_Login: break; /** @todo TODO: implement */
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
default: break;
case protocol_Lobby_CreateGame: break; /** @todo TODO: implement */
case protocol_Lobby_StartGame: break; /** @todo TODO: implement */
case protocol_Lobby_JoinGame: break; /** @todo TODO: implement */
case protocol_Lobby_Login: break; /** @todo TODO: implement */
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
default: break;
}
}
else if( ProtocolIsGeneral(ID) )

View File

@ -120,14 +120,14 @@ void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEve
{
switch(ID)
{
case protocol_Lobby_Create: break; /** @todo TODO: implement */
case protocol_Lobby_Start: break; /** @todo TODO: implement */
case protocol_Lobby_Join: break; /** @todo TODO: implement */
case protocol_Lobby_Login: break; /** @todo TODO: implement */
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
default: break;
case protocol_Lobby_CreateGame: break; /** @todo TODO: implement */
case protocol_Lobby_StartGame: break; /** @todo TODO: implement */
case protocol_Lobby_JoinGame: break; /** @todo TODO: implement */
case protocol_Lobby_Login: break; /** @todo TODO: implement */
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
default: break;
}
}
else if( ProtocolIsGeneral(ID) )

View File

@ -1,17 +1,19 @@
#include "NetLoadState.h"
#include "NetworkClient.h"
#include "../Game/GameProtocols/ProtocolIdentificationID.h"
#include "../Game/GameProtocols/Protocols.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
using namespace ::Oyster::Network;
using namespace ::GameLogic;
struct NetLoadState::MyData
{
MyData() {}
GameClientState::ClientState nextState;
//NetworkClient *nwClient; needed?
NetworkClient *nwClient;
bool loading;
};
NetLoadState::NetLoadState(void) {}
@ -27,12 +29,12 @@ bool NetLoadState::Init( NetworkClient* nwClient )
this->privData = new MyData();
this->privData->nextState = GameClientState::ClientState_Same;
//this->privData->nwClient = nwClient; needed?
this->privData->nwClient = nwClient;
this->privData->loading = false;
// we may assume that nwClient is properly connected to the server
this->privData->nextState = GameClientState::ClientState_Main;
// signals querry to server for loading instructions
nwClient->Send( Protocol_QuerryGameType() );
return true;
}
@ -63,24 +65,20 @@ void NetLoadState::ChangeState( ClientState next )
void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.
// fetching the id data.
short ID = e.args.data.protocol[0].value.netShort;
//if( ProtocolIsGameplay(ID) )
//{
// switch(ID)
// {
// //case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
// default: break;
// }
//}
//else if( ProtocolIsGeneral(ID) )
//{
// switch( ID )
// {
// case protocol_General_Status: break; /** @todo TODO: implement */
// case protocol_General_Text: break; /** @todo TODO: implement */
// default: break;
// }
//}
}
if( ID == protocol_Lobby_CreateGame && !this->privData->loading )
{
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
}
}
void NetLoadState::LoadGame( const ::std::string &fileName )
{
this->privData->loading = true;
// TODO: ask Sam about level loader
this->privData->nextState = ClientState::ClientState_Game;
}

View File

@ -26,6 +26,8 @@ namespace DanBias
private:
struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData;
void LoadGame( const ::std::string &fileName );
};
}
}

View File

@ -21,6 +21,24 @@
namespace GameLogic
{
struct Protocol_QuerryGameType :public Oyster::Network::CustomProtocolObject
{
public:
Protocol_QuerryGameType()
{
this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_QuerryGameType;
}
::Oyster::Network::CustomNetProtocol GetProtocol() override
{
return this->protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
{
short clientID; // The unuiqe id reprsenting a specific client
@ -30,7 +48,7 @@ namespace GameLogic
Protocol_LobbyCreateGame()
{
int c = 0;
this->protocol[c].value = protocol_Lobby_Create;
this->protocol[c].value = protocol_Lobby_CreateGame;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
@ -43,7 +61,7 @@ namespace GameLogic
Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16])
{
int c = 0;
this->protocol[c].value = protocol_Lobby_Create;
this->protocol[c].value = protocol_Lobby_CreateGame;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
@ -92,14 +110,14 @@ namespace GameLogic
Protocol_LobbyStartGame()
{
this->protocol[0].value = protocol_Lobby_Start;
this->protocol[0].value = protocol_Lobby_StartGame;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
seconds = 0;
}
Protocol_LobbyStartGame(float _seconds)
{
this->protocol[0].value = protocol_Lobby_Start;
this->protocol[0].value = protocol_Lobby_StartGame;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
seconds = _seconds;
@ -119,17 +137,17 @@ namespace GameLogic
};
struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject
struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject
{
// Login stuff
Protocol_LobbyLogin()
Protocol_LobbyJoinGame()
{
this->protocol[0].value = protocol_Lobby_Join;
this->protocol[0].value = protocol_Lobby_JoinGame;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
}
Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p)
Protocol_LobbyJoinGame(Oyster::Network::CustomNetProtocol& p)
{
}

View File

@ -27,13 +27,14 @@
/********* LOBBY PROTOCOLS ***************************************************************************************************/
/***********[ 200 - 299 ]***********/
#define protocol_LobbyMIN 200
#define protocol_Lobby_Create 200
#define protocol_Lobby_Start 201
#define protocol_Lobby_Join 202
#define protocol_Lobby_CreateGame 200
#define protocol_Lobby_StartGame 201
#define protocol_Lobby_JoinGame 202
#define protocol_Lobby_Login 203
#define protocol_Lobby_Refresh 204
#define protocol_Lobby_ClientData 205
#define protocol_Lobby_GameData 206
#define protocol_Lobby_QuerryGameType 207
#define protocol_LobbyMAX 299

View File

@ -40,7 +40,7 @@ namespace DanBias
//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:
void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:

View File

@ -15,11 +15,11 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
break;
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
//break;
case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
break;
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
//break;
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyLogin (p), c);
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c);
break;
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
break;
@ -82,7 +82,7 @@ void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Ne
// // }
// //}
//}
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c)
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
{
}

View File

@ -38,7 +38,7 @@ void ClientFnc()
gameDesc.IP = "127.0.0.1";
//gameDesc.IP = "194.47.150.184";
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess)
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Success)
{
DanBias::DanBiasGame::Run();
DanBias::DanBiasGame::Release();