EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

kryonet protocol #56

Closed sanjeev909 closed 9 years ago

sanjeev909 commented 10 years ago

Hi,

As I dig deeper into the kryonet/kryo libraries, I appreciate the power and simplicity of the framework. Amazing work folks.

I'm trying to serialize cocoa-objects over a socket connection to kryonet server. The server is correctly matching the source class to registered class and completing the serialization at the server end.

I'm almost there, but for the following issues -

  1. The first field in the source is getting serialized to second, the second(source) to third (destination) and so-on.
  2. Strings are not getting serialized correctly because I'm not specifying the format (ascii/utf8) in the buffer. How is this done?

Will appreciate if you can point to the protocol elements to be inserted in the buffer.

Regards Sanjeev

NathanSweet commented 10 years ago

KryoNet uses Kryo for serialization. Kryo doesn't have a schema specification. It is intended that the same version of Kryo is on both ends. This simplifies many things but makes it difficult if not using the same version of Kryo on both ends.

sanjeev909 commented 10 years ago

Thanks Nathan,

Does kryonet not add its own elements to the transmitted buffer, like it prefixes the length of the content in the first 4 bytes.

thanks Sanjeev

sanjeev909 commented 10 years ago

Found the cause for the problem...

Method writeReferenceOrNull()...inserts a byte at position 2...but while reading position-2 is not read as a reference.

What are references, and how do they synch up?

This is the line of code in Kryo.java that adds a reference

if (references && writeReferenceOrNull(output, object, false)) { registration.getSerializer().setGenerics(this, null); return; }

sanjeev909 commented 10 years ago

Got it. Thats because references is false in the server, while it was true in the client.

tanis2000 commented 10 years ago

@sanjeev909 are you planning on releasing your Cocoa version of the kryonet library by any chance?

sreich commented 9 years ago

could we close this issue if it is no longer needed?