Sign in to follow this  
EternityZA

Java Serialization

Recommended Posts

EternityZA    1226
Hi.

I’m currently creating an online multiplayer FPS. I have a working client and server and 12 people can play together on a LAN with no lag. The client and the server is written in java. I’ve created my own crude binary protocol for communication between the clients and the server. I’ve taken care to make sure nothing gets send that isn’t necessary. The player position update frequency is 20 Hz.

I’ve been looking at java serialization to make my life a little easier when it comes to sending/receiving game data but I don’t know what the overhead is for using it. Also I fear that if I use java serialization it might complicate things if I later want to swap to using UDP. I get the feeling java serialization is more aimed at enterprise java but I hope I'm wrong.

I have no problem continuing without serialization if there’s any disadvantage to using it for a multiplayer FPS. I would just like to know.

Thnx in Advance!

Share this post


Link to post
Share on other sites
rip-off    10976
Java serialisation was not design for low latency scenarios like an FPS over the internet. I would expect it to perform poorly compared to your own binary protocol. I believe the overhead is high enough. If you are not careful you can end up serialising an entire object graph, which is obviously expensive.

If you had not already implemented your own protocol, you could have used it as a placeholder implementation to get you up and running quickly.

You will probably need to switch to UDP if you want to support an action game over the internet. On a LAN there is likely no packet loss, but if you encounter packet loss with TCP it can introduce a lot of artificial latency. For completeness, I will say that you can use Java serialisation with UDP. You can tell it to output to something like a ByteArrayOutputStream and then turn that into a UDP packet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this