Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,655 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
C++ engine server communicating with WDL client #112019
02/15/07 09:57
02/15/07 09:57
Joined: Oct 2006
Posts: 23
K
Kresimir Offline OP
Newbie
Kresimir  Offline OP
Newbie
K

Joined: Oct 2006
Posts: 23
Hi!

I need to be able to play >16bit WMVs in my games, and since Game Studio cannot handle those well i decided i'd create a C++ server that could display the movies and get messages from a client when to display which movie.

I'm having problems with their communication. I can get the WDL client to connect to my C++ server and the client can receive messages (strings) from the server, but server cannot receive any messages from the client.

Here's a bit of code from my C++ server.
Code:

STRING* sending_string;

void server_communication(STRING* str)
{
MessageBox(0, L"Server function called!", L"Title", 0);
str_cpy( sending_string, str->chars );
}

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
...<some irrelevant code goes here>...

sending_string = str_create("");
v(on_server) = (EVENT)server_communication;
level_load((char*)level_name.c_str());

...<some irrelevant code goes here>...

while( engine_frame() )
{
if( v(key_g) )
{
str_cpy( sending_string, "someStringMessage" );
send_string( sending_string );
}
}

...<some irrelevant code goes here>...
}



When i press the "g" key in my server, the client receives the string...

Here's a bit of code from the client that receives the string.
Code:

function client_communication( str )
{
if( event_type == event_string )
{
str_cpy( sending_string, str );
}
}

on_client = client_communication;



That part works fine. But when i send the string from client like this:
Code:

string sending_string;
function send_message_to_server()
{
str_cpy( sending_string, "someMessageToServer" );
send_string( sending_string );
}

on_h = send_message_to_server;


i do not receive anything on server.

I noticed that server's "on_server" function gets called only when the client connects and disconnects from the server. Also, i am sure that the client connects successfully to the server, because it receives server's messages.

What am i missing? Why doesn't the server receive the string from client?

Thanks,
Kresimir

Re: C++ engine server communicating with WDL clien [Re: Kresimir] #112020
02/19/07 08:06
02/19/07 08:06
Joined: Oct 2006
Posts: 23
K
Kresimir Offline OP
Newbie
Kresimir  Offline OP
Newbie
K

Joined: Oct 2006
Posts: 23
Anybody has any suggestions?

Did anyone ever try anything similar?

Re: C++ engine server communicating with WDL clien [Re: Kresimir] #112021
02/19/07 12:53
02/19/07 12:53
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Puppeteer Offline
Expert
Puppeteer  Offline
Expert

Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
i think theres an event_receive or something like that....


Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com
Re: C++ engine server communicating with WDL client [Re: Kresimir] #112022
02/19/07 22:14
02/19/07 22:14
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Are you using separate code for the client and server or are you using the same code with IFDEF in them?

Point is that you have to be aware that the strings are indexed and have to be in the same place on both client and server. So if you define a new string on the client that the server doesn't know about, you will not get through.

Put all your variable and string definitions on the top of your code before you do anything else. This will make sure that you have those defined on both client and server and that they are properly indexed.

Re: C++ engine server communicating with WDL clien [Re: fastlane69] #112023
02/20/07 08:17
02/20/07 08:17
Joined: Oct 2006
Posts: 23
K
Kresimir Offline OP
Newbie
Kresimir  Offline OP
Newbie
K

Joined: Oct 2006
Posts: 23
Quote:

Are you using separate code for the client and server or are you using the same code with IFDEF in them?



I'm using a WDL script as my client, and C++ code as my server. So it's separate.

Quote:

Point is that you have to be aware that the strings are indexed and have to be in the same place on both client and server. So if you define a new string on the client that the server doesn't know about, you will not get through.



I'm aware of that, and when i had to make a multiplayer part of code in WDL, i followed the Locoweed's tutorial and got everything working nicely with global strings. Problem now is that the client code is in WDL, and the server code is a project in C++. WDL client can receive strings from C++ server, but C++ server cannot receive a string from a WDL client.

Quote:

Put all your variable and string definitions on the top of your code before you do anything else. This will make sure that you have those defined on both client and server and that they are properly indexed.



I'd love to, but i can't, since they don't share a "source" file.

Re: C++ engine server communicating with WDL clien [Re: Puppeteer] #112024
02/20/07 08:31
02/20/07 08:31
Joined: Oct 2006
Posts: 23
K
Kresimir Offline OP
Newbie
Kresimir  Offline OP
Newbie
K

Joined: Oct 2006
Posts: 23
Quote:

i think theres an event_receive or something like that....



Event_receive is set when an entity's skill is sent. Since i'm sending strings, i cannot use this unless i create a global entity on the server and use it's skills instead of strings to pass my messages.

I don't think i have to explain this solution would not work if i need to send messages whose content i do not know prior to compiling my game (example: chat).

Re: C++ engine server communicating with WDL clien [Re: Kresimir] #112025
02/21/07 14:27
02/21/07 14:27
Joined: Oct 2006
Posts: 23
K
Kresimir Offline OP
Newbie
Kresimir  Offline OP
Newbie
K

Joined: Oct 2006
Posts: 23
I've solved it. Thanks for your help.

This sentence helped me the most:
Quote:

Point is that you have to be aware that the strings are indexed and have to be in the same place on both client and server.




Last edited by Kresimir; 02/21/07 14:27.

Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1