Game Networking Framework

So I have an issue with working with UDP Socketing. The problem is in my Game Engine, I send over information about a Game Object from the Server to the Client, and if that Game Object doesn’t exist, I would create one, but the problem is that every class is different, and has a different constructor, so creating a new object would be difficult. how would I fix this problem? :-\

So… Why don’t you send over the constructor’s parameters?

Would you give an example please? :o

Well when I worked with a Client-Server-System the Server send messages in some pseudo XML, something like this:


begin:foobar
begin:intlist
0
1
2
end:intlist
length: 3
end:foobar

So let’s assume you have a Player class with an ID, x, y, hp and mp. Your server messages could look like this:


begin:player
id:1234
x:5
y:8
hp:321
mp:234
end:player

After that you could parse that messages, possibly with a recursive descent parser.
You could also send a message “Player(1234,5,8,321,234)”, you just have to know how to parse your message for the constructor.

Does that help? :slight_smile:

I highly suggest to use Kryonet. It allows sending java objects over the internet via TCP / UDP with a lot of useful optimizations. It’s pretty much the fastest Serialization library (Kryo) together with a very fast network implementation.

I’m going to keep doing my own socketing so that I can use it at it’s fullest. @Silver Tiger, sadly that did not help, I had something similar to that already setup. Please read the main topic more.

P.S. Not trying to be a dick, I appreciate your time, and effort.

So, basically, you want to send Objects over to the server regardless of the structure, store them, and be able to read them back with no questions asked. Maybe some more information about these Objects would help people a little more. Try answering these questions…

  1. Do these Objects have a maximum size?
  2. Does data loss of these objects matter?

To be honest, the request sounds unreasonable for UDP. I believe researching how to use Kyronet would be the correct solution as you are heavily hinting at serialization and storage. At least, in this case, you’d be able to handle new requests client side. The server can care less what data is stored, it is just up to the client to keep track on where to look for data when it is on the server.