RTS networking datagram Java strategy help needed
Posted on 2011-09-13
For my Java RTS,
I am now doing the networking. I can send datagrams between server and client,
but with limited bytes, how should I convey movement directions for multiple units?
I think a major problem is bytes are too small for the data members I am using, integers and possibly occasional strings.
In my arrays of unit X and Y positions, what is the simplest way to send all client (player) data to server, and on to each client?
Could I make a struct array of all the relevant data members for each unit? X, Y, HitPoints etc
and have a method to send and receive arrays of structures?
Is there something as simple as toByteArray() and getByteArray()? for objects / struct arrays?
For synchronization, should each client send out movement info for each frame? - or only when an instruction( move) occurs?
Any other comments?
Should I use a struct in the connection that contains fields for every possible communication need?
I may need an initial header up front containing synch info (frame counts)