Solved

RTS networking datagram Java strategy help needed

Posted on 2011-09-13
3
288 Views
Last Modified: 2012-05-12
Hi,

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)

What else?

Thx
0
Comment
Question by:beavoid
3 Comments
 
LVL 16

Expert Comment

by:SteveJ
Comment Utility
I dont understand your app. You say "bytes are too small" and Im not sure what you mean by that, because the obvious response is send more bytes. Java as I sure you know has lots if methods for sending data .  .  . and whether or not you send field names etc has to do with your app not Java read / write operations. And try to use the upper layer protocols so that you are not re-writing TCP/IP.

Good luck,
Steve

By the way, java and gaming? Im no programmer but Id think java was eay too slow for gaming. C?
0
 

Author Comment

by:beavoid
Comment Utility
In my case, Java is perfect.
I think, now, I'd like to know how I can send a whole struct of data members between two sockets. By two small, I simply meant that bytes are smaller than ints and Strings. and sockets only send bytes.
Can I design a struct (must it be a class?) that contains all data I'll need to communicate and send it safely between sockets, even though it must be byte sized data?
0
 
LVL 39

Accepted Solution

by:
noci earned 500 total points
Comment Utility
If you need 1 to many cummunication you might opt for Multicast.
That is not relyable in the sense that UDP is employed and you cannot ask for a retransmit on the multicast ports....

If it point -> point then you have to devise some protocol of your own.
The data to be conveyed needs to be put in some structure that you send around as a packet.
Keep it small so updates allways fit in one MTU.

I have no experience with java except that for realtime stuff it tends to degrade.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now