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 / End of network message?

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Dec 2017 11:12
Hello peeps

I use network messsages, but I would like to know the end of the message. I did a small test where I would send 1 integer, and try to read 2 integers but this performs undefined behavior as even though there is only 1 integer in the message the receiving end will still read 2 integers. Is there any way to know whether or not end message has been reached. I would like to know so I can discard message in case of bad data received.
13/0
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 7th Dec 2017 16:55
No.

I recommend using a first integer on each message which determines the "command".

You read the first integer (the command) and then you can use conditions on this command number to read the correct number of next elements (integer, float, string..)

Use constants for command number
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Dec 2017 18:20
I already have a "packet_operation" integer at the beginning of each message I have several different loops with network messages but they shouldn't be able to mess each other up as I use unique identifiers. So it isn't possible for a packet that arrived to be missing data?

About the constants, are they faster to use for a machine or just easier to read for a human interfacer?
13/0
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Dec 2017 18:30 Edited at: 7th Dec 2017 18:35
Quote: "So it isn't possible for a packet that arrived to be missing data?
About the constants, are they faster to use for a machine or just easier to read for a human interfacer?"


i think agk handle a message compleate.
constants are just not changeable from within code and yes, its better than having 1,2,3 in code and you not know what it means.
in other languages u will use a enumeration.
myself using a packed id as string, i send "abc" and the other side have a select cmd$ case "abc".
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 7th Dec 2017 19:39
i prefer numeric command messages with constants (easier to read in code) (and less bytes to transfer for each messages).

There is a size defined at the beginning of each messages in the packets (i use it for my multiplayer server to intercept messages and do eventually something with). But there is no way in Tier 1 to know the types and how many variables are in the message. That is a flat message which requires to know the exact structure when you receive it. That the only way to reduce drastically the bytes count for transfers (and it's the better choice).

Login to post a reply

Server time is: 2024-04-25 12:28:34
Your offset time is: 2024-04-25 12:28:34