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