Horde3D

Next-Generation Graphics Engine
It is currently 09.11.2024, 00:53

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Multiplayer networking?
PostPosted: 26.09.2012, 13:50 
Offline

Joined: 09.02.2011, 17:02
Posts: 83
I am facing a problem with multiplayer networking. All that I am doing is that I start a server by calling a function Mystartserver();
Before this function my variable named m_networkstarted is set as false but as soon as i start server once i set it to true.

Code:
Mystartserver(){
if (m_networkStarted)
      return;
   m_networkStarted = true;
GameEngine::startServer();
GameEngine::registerCallbackOnClientConnect(NetworkApp::clientConnectCb);}

While in my client i am doing folowing things

Code:
Myclient(const char* character, int spectator){
m_networkStarted = true;
const char* serverip = "127.0.0.1";
GameEngine::connectToServer(serverip);
if (m_networkStarted){
   if(spectator > 0)   {
      m_spectator = true;
      m_character = GameEngine::entityWorldID("Hans");
      m_spectatorNum = spectator;
      h3dSetupCameraView(GameEngine::entitySceneGraphID(m_camID),73.7f,4.0f / 3.0f, 0.1f, 1000.0f);   }
   else{         
      m_character = GameEngine::entityWorldID(character);
      m_NPC = GameEngine::entityWorldID("Emilia");   }

   if(!m_spectator)   {
      GameEngine::registerCallbackOnStateRequest(NetworkApp::stateRequestCb);   }

   if(m_spectator){
      const char* serverip = "127.0.0.1";
        GameEngine::connectToServer(serverip);
      GameEngine::registerCallbackOnStateRequest(NetworkApp::stateRequestCb);   }
   }

else   {return;}

}


Now when i am running the application (.exe) first time I am calling the server once. I run another (new) exe on same computer and then i call the client 1. It works and is connected to the server. Then I run 3rd .exe and then i call my client function again and this is the second time my client is called. so now when i do this i get the status on my screen that it is connected and after half a second its shows as it is Disconnected. What is the wrong in connecting a client that i am doing ?

Although client is running but it is not connected to the server. what possible reason could it be?

i just don't get why one client gets connected while when second client is connecting it is connected for half a second and then it is disconnected?


Top
 Profile  
Reply with quote  
PostPosted: 26.09.2012, 15:19 
Offline

Joined: 09.02.2011, 17:02
Posts: 83
Ok now i know what mistake i am doing . Probably when i am using this function while creating server it is not allowing me connect new clients but when i remove this i can attach as many client as i can.
Code:
GameEngine::registerCallbackOnClientConnect(NetworkApp::clientConnectCb);



But now problem here is that client 1 is not updating according to client 2. my client 1 is attached with hans as a view while client 2 is also attached with hans as a left view. so its attached as left view but its not updating as client 1 is updating . Does some one has any idea how can i update client 2 if client 1 is changing its position?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group