Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (BrainSailor, AndrewAMD), 1,662 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Cant send strings to server nor client? #270393
06/08/09 06:34
06/08/09 06:34
Joined: May 2009
Posts: 258
Chicago
J
Jaeger Offline OP
Member
Jaeger  Offline OP
Member
J

Joined: May 2009
Posts: 258
Chicago
Hey guys,

I've been working on a fairly simple chat app. The GUI and everything looks great, and works well, but this networking stuff is driving me nuts. It seems like it should be pretty simple, but I can't get it to work.

I found a chat example from Michael Schwarz which is written in C-script. I adapted it to Lite-C, but it doesn't work. It doesn't send the string to the server, or the client when it should. The other problem, is in his code, it empties the strings "to avoid duplication" it says, but that just makes it so you can't type any more messages, lol. I guess that can be easily fixed by just str_cpy'ing blank spaces back in though. The real issue is the networking code not working.

So, I tried writing my own functions/events (simplified version) to see if I could send the string, then have it displayed on the screen. It doesn't work either. It seems to me it's either not sending/receiving the string, or the event is not being triggered. Here's the simple code I wrote:

Code:

STRING* chatline01_str = "#50";
STRING* test_str = "TESTING 123!!!";
STRING* test2_str = "#50";

//Then of course, I have TEXT objects to display the strings
// I'm just omitting those to save space
....

function send_msg()
{
	wait(1);
	send_string(test_str);
	wait(1);
}

function server_event(void* str,var id)
{
	switch(event_type)
	{
		case EVENT_STRING:
		wait(1);
		
		send_string(test_str);
		wait(1);
	}
}

function client_event(void* str,var id)
{
	switch(event_type)
	{
		case EVENT_STRING:
		wait(1);
		
		str_cpy(chatline01_str,test_str);
		wait(1);

	}
}
...

// Then I put these in a function loop which continually runs
// the whole time the program does...

on_esc = exit_app;
on_server = server_event; 
on_enter = send_msg;
on_client = client_event;



My on_esc event works fine when I press esc, and runs my function that prompts the user with whether or not they intend to exit.

However, the code you see above will not pass the STRING to the server or client to display it on screen. Well, I really think the events aren't being triggered. If I type in chatline01_str in the console, it just adds "=" behind it. If I type in test_str, it adds "= TESTING 123!". You know what I mean. So it's obviously never reaching this:

str_cpy(chatline01_str,test_str);

And probably not even running the server event to send it in the first place. So, I'm kind of out of ideas now. I've tried putting the on_event code outside the loop, and in many different places. It does no good. I also tried the event functions without any parameters/args, tried some with and some without, different combinations, all of them with params/args, and it made no difference.

Last edited by Jaeger; 06/08/09 06:36.
Re: Cant send strings to server nor client? [Re: Jaeger] #270434
06/08/09 10:51
06/08/09 10:51
Joined: May 2009
Posts: 258
Chicago
J
Jaeger Offline OP
Member
Jaeger  Offline OP
Member
J

Joined: May 2009
Posts: 258
Chicago
Ah nevermind... Stupid user error! smile Will work again tomorrow, and post results...

If you do see a problem with the code, or have suggestions, I'll still be glad to hear it though!

Thanks,


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | 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