You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 18, 2025. It is now read-only.
AlexTape edited this page Jun 11, 2015
·
2 revisions
Hints
The API provides an implementation of the native object serialization routine:
ObjectSerializerImpl.objectToString(final Serializable object);
ObjectSerializerImpl.stringToObject(final String string, final Class<E> clazz);
With these methods you are able to send objects directly:
AnyObject any = new AnyObject();
String serializedObject = ObjectSerializerImpl.objectToString(any);
ClientProvider.sendGameMessage(serializedObject);
Remember that the receiver has to know which object is being sent. So you need the Class of
the serialized object on both sides (sender and receiver).
If the receiver wants to pick the serialized object, just do this:
/**
* UniBoxClient: bind event handler for incoming messages.
*/
ClientProvider.bind(primaryStage, new IncomingMessageHandler() {
@Override
public void handle(final String user, final String msg) {
AnyObject any = ObjectSerializerImpl.stringToObject(msg, AnyClass.class);
// any is an exact copy of the object send by the sender
}
});
Just food for thought. You can even capsule objects:
ArrayList<AnyObject> list = new ArrayList<AnyObject>();
list.add(obj1);
list.add(obj2);
String serializedObject = ObjectSerializerImpl.objectToString(list);
ClientProvider.sendGameMessage(serializedObject);
Bugs
In Internet Explorer 11 the Chat-Function doesn't work until the app receives the second/third incoming message.