About Store Forum Documentation Contact



Post Reply 
new to this world :O
Author Message
Vergan Offline
Member

Post: #1
new to this world :O
I know a bit of programming, but i'm new to this network thing, i need your help :(

I followed the code snippet (Connection - Server.cpp and Connection - Client.cpp)


but i can't completely understand it... i tryed to make the client connect to itself (which would allow me to make a multiplayer basic FPS more easily).

here's the code:
PHP Code:
/******************************************************************************/
#include "stdafx.h"
#include "$$headers.h"
/******************************************************************************/
ConnectionServer mServer;
Connection mSelf;
Str text;
Str data;
/******************************************************************************/
void InitPre(){
   
App.name("Client");
   
App.flag APP_WORK_IN_BACKGROUND;
   
DataPath("C:/EsenthelEngineSDK/Data");
   
Paks.add("engine.pak");
   
D.mode(640480);   
   
D.full(false);
}
/******************************************************************************/
Bool Init()
{
   if(!
mServer.create(55874))
      Exit(
"Couldn\'t create the server.");
      
   
mServer.clients.replaceClass<Client>();
   
   
SockAddr serverserver.setLocal(55874);
   
   if(
mSelf.clientConnectToServer(server))
   {
   }
   else {
      return 
false;
   }
   return 
true;   
}
/******************************************************************************/
void Shut()
{
   
mServer.del();
   
mSelf.del();
}
/******************************************************************************/
Bool Update()
{
   
mServer.update();
   
/*if (mSelf.state() == CONNECT_VERSION_CONFLICT) text += " | Version Trouble";
   else if (mSelf.state() == CONNECT_INVALID) text += " | Invalid";
   else if (mSelf.state() == CONNECT_AWAIT_GREET) text += " | Connecting...";
   else if (mSelf.state() == CONNECT_GREETED) text += " | Success!"; */
   
if(Kb.bp(KB_ESC))
      return 
false;
   return 
true;
   
   if (
mSelf.receive(0))
   {
      
mSelf.data.getStr(data);
   }
}
/******************************************************************************/
void Draw()
{
    if(
mSelf.state()!=CONNECT_GREETED)
      
text += " | Invalid connection";
      
   
D.clear(BLACK);
   
D.text(00.8text);
   
   
text "";   


the connection always return CONNECT_AWAIT_GREET. please... i don't understand what i'm doin' wrong...
03-25-2011 01:46 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: new to this world :O
return true;

if (mSelf.receive(0))
{
mSelf.data.getStr(data);
}

due to your return you're not processing 'receive' which is needed for greeting
03-25-2011 02:00 PM
Find all posts by this user Quote this message in a reply
Vergan Offline
Member

Post: #3
RE: new to this world :O
Argh! i wasn't even paying attention to this return anymore -_- Thank you very much, i wouldn't have found it by myself xD.
(This post was last modified: 03-25-2011 02:34 PM by Vergan.)
03-25-2011 02:33 PM
Find all posts by this user Quote this message in a reply
Post Reply