Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / T2 Networks

Author
Message
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 9th Dec 2012 15:31
Hi guys, I have been trying to get a multiplayer netowrk... thingy... working. But I am having some problems with the messages.

This is the code recieving the messages:






However, the clinet spits out "Message does not exist 10001" and if I use the debugger in VS2010, GetNetworkMessage returns a bigger ID each frame and the DeleteNetworkMessage command dosn't seem to do anything at all. Am I doing something wrong, or is this yet another bug in AppGameKit? Im using 1085 BTW
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Dec 2012 17:49
Quote: "if (msgType = "Sector data")"

You cannot do this in C++.

First, in doing comparisons you need to use '==' (two equals signs). A single equals sign does an assignment (and it will do that in the if statement).

Next, that is not how you do string comparisons in C++. Add "#include <string.h>" to to top of your file (and the < and > are the actual characters to use in this case). Then change the comparison to: if (strcmpi(msgType,"Sector data")==0)

That should fix some of your problems.

And remember to delete the message when you are done with: delete msgType;

If you don't do the delete, you will suffer from a memory leak.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 9th Dec 2012 17:57 Edited at: 9th Dec 2012 18:02
Quote: "You cannot do this in C++."


Oh of course, I realy wish the compiler would atleast warn me about that kind of things. But if im not mistaken, changing that wont change the fact that the "deleteNetworkMessage" command dosn't work and msg increases by 1 every time the while loop runs.

Quote: "And remember to delete the message when you are done with: delete msgType;"


Didn't think about that one.

Thanks for your help as allways!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Dec 2012 19:18
How is the deleteNetworkMessage command not working?

The message id will always increase. The id doesn't get reused. Each message needs its own unique id.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 9th Dec 2012 20:17
Oh, it looks like the problem that I thought had something to do with the message ID's was because I used my networkID instead of my msg variable.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Dec 2012 20:26
Glad you figured it out.

Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-04-28 13:48:45
Your offset time is: 2024-04-28 13:48:45