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,9 +120,9 @@ void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::Clie
{ {
switch(ID) switch(ID)
{ {
case protocol_Lobby_Create: break; /** @todo TODO: implement */ case protocol_Lobby_CreateGame: break; /** @todo TODO: implement */
case protocol_Lobby_Start: break; /** @todo TODO: implement */ case protocol_Lobby_StartGame: break; /** @todo TODO: implement */
case protocol_Lobby_Join: break; /** @todo TODO: implement */ case protocol_Lobby_JoinGame: break; /** @todo TODO: implement */
case protocol_Lobby_Login: break; /** @todo TODO: implement */ case protocol_Lobby_Login: break; /** @todo TODO: implement */
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */ case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */ case protocol_Lobby_ClientData: break; /** @todo TODO: implement */

View File

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

View File

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

View File

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

View File

@ -21,6 +21,24 @@
namespace GameLogic 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 struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
{ {
short clientID; // The unuiqe id reprsenting a specific client short clientID; // The unuiqe id reprsenting a specific client
@ -30,7 +48,7 @@ namespace GameLogic
Protocol_LobbyCreateGame() Protocol_LobbyCreateGame()
{ {
int c = 0; 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;
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]) Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16])
{ {
int c = 0; 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;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
@ -92,14 +110,14 @@ namespace GameLogic
Protocol_LobbyStartGame() 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[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
seconds = 0; seconds = 0;
} }
Protocol_LobbyStartGame(float _seconds) 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[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
seconds = _seconds; seconds = _seconds;
@ -119,17 +137,17 @@ namespace GameLogic
}; };
struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject
{ {
// Login stuff // 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[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].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 ***************************************************************************************************/ /********* LOBBY PROTOCOLS ***************************************************************************************************/
/***********[ 200 - 299 ]***********/ /***********[ 200 - 299 ]***********/
#define protocol_LobbyMIN 200 #define protocol_LobbyMIN 200
#define protocol_Lobby_Create 200 #define protocol_Lobby_CreateGame 200
#define protocol_Lobby_Start 201 #define protocol_Lobby_StartGame 201
#define protocol_Lobby_Join 202 #define protocol_Lobby_JoinGame 202
#define protocol_Lobby_Login 203 #define protocol_Lobby_Login 203
#define protocol_Lobby_Refresh 204 #define protocol_Lobby_Refresh 204
#define protocol_Lobby_ClientData 205 #define protocol_Lobby_ClientData 205
#define protocol_Lobby_GameData 206 #define protocol_Lobby_GameData 206
#define protocol_Lobby_QuerryGameType 207
#define protocol_LobbyMAX 299 #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 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 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 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 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 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: 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; break;
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c); //case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
//break; //break;
case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c); case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
break; break;
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c); //case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
//break; //break;
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyLogin (p), c); case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c);
break; break;
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c); case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
break; 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 = "127.0.0.1";
//gameDesc.IP = "194.47.150.184"; //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::Run();
DanBias::DanBiasGame::Release(); DanBias::DanBiasGame::Release();