use of org.terasology.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.
the class NetworkSubsystem method initialise.
@Override
public void initialise(GameEngine engine, Context rootContext) {
networkSystem = new NetworkSystemImpl(rootContext.get(Time.class), rootContext);
rootContext.put(NetworkSystem.class, networkSystem);
}
use of org.terasology.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupNetwork.
@Override
protected void setupNetwork() {
EngineTime mockTime = mock(EngineTime.class);
context.put(Time.class, mockTime);
NetworkSystem networkSystem = new NetworkSystemImpl(mockTime, getContext());
context.put(NetworkSystem.class, networkSystem);
}
use of org.terasology.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.
the class SetupRemotePlayer method step.
@Override
public boolean step() {
NetworkSystemImpl networkSystem = (NetworkSystemImpl) context.get(NetworkSystem.class);
EntityRef client = networkSystem.getServer().getClientEntity();
if (client.exists()) {
context.get(LocalPlayer.class).setClientEntity(client);
return true;
}
return false;
}
use of org.terasology.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.
the class TestNetwork method testEntityNetworkIdChangedOnServerStart.
@Test
public void testEntityNetworkIdChangedOnServerStart() throws HostingFailedException {
EngineEntityManager entityManager = getEntityManager();
NetworkComponent netComp = new NetworkComponent();
netComp.setNetworkId(122);
EntityRef entity = entityManager.create(netComp);
EngineTime time = mock(EngineTime.class);
NetworkSystem server = new NetworkSystemImpl(time, context);
server.setContext(context);
netSystems.add(server);
server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
server.host(7777, true);
assertFalse(122 == entity.getComponent(NetworkComponent.class).getNetworkId());
server.shutdown();
}
use of org.terasology.network.internal.NetworkSystemImpl in project Terasology by MovingBlocks.
the class TestNetwork method testNetwork.
@Test
public void testNetwork() throws Exception {
EngineEntityManager entityManager = getEntityManager();
EngineTime time = mock(EngineTime.class);
NetworkSystem server = new NetworkSystemImpl(time, context);
server.setContext(context);
netSystems.add(server);
server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
server.host(7777, true);
Thread.sleep(500);
NetworkSystem client = new NetworkSystemImpl(time, context);
client.setContext(context);
netSystems.add(client);
client.join("localhost", 7777);
Thread.sleep(500);
server.shutdown();
client.shutdown();
}
Aggregations