public class RmiSendObjectTest extends KryoNetTestCase {
/** In this test the server has two objects in an object space. The client uses the first remote object to get the second remote
* object. */
public void testRMI () throws IOException {
Server server = new Server();
Kryo serverKryo = server.getKryo();
register(serverKryo);
// After all common registrations, register OtherObjectImpl only on the server using the remote object interface ID.
// This causes OtherObjectImpl to be serialized as OtherObject.
int otherObjectID = serverKryo.getRegistration(OtherObject.class).getId();
serverKryo.register(OtherObjectImpl.class, new RemoteObjectSerializer(), otherObjectID);
startEndPoint(server);
server.bind(tcpPort);
// TestObjectImpl has a reference to an OtherObjectImpl.
final TestObjectImpl serverTestObject = new TestObjectImpl();
serverTestObject.otherObject = new OtherObjectImpl();
// Both objects must be registered with the ObjectSpace.
final ObjectSpace serverObjectSpace = new ObjectSpace();
serverObjectSpace.register(42, serverTestObject);
serverObjectSpace.register(777, serverTestObject.getOtherObject());
server.addListener(new Listener() {
public void connected (final Connection connection) {
// Allow the connection to access objects in the ObjectSpace.
serverObjectSpace.addConnection(connection);
}