/** Serializes an object registered with an ObjectSpace so the receiving side gets a {@link RemoteObject} proxy rather than the
* bytes for the serialized object.
* @author Nathan Sweet <misc@n4te.com> */
static public class RemoteObjectSerializer extends Serializer {
public void write (Kryo kryo, Output output, Object object) {
Connection connection = (Connection)kryo.getContext().get("connection");
int id = getRegisteredID(connection, object);
if (id == Integer.MAX_VALUE) throw new KryoNetException("Object not found in an ObjectSpace: " + object);
output.writeInt(id, true);
}