Search in sources :

Example 1 with NetworkSystemImpl

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);
}
Also used : NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl)

Example 2 with NetworkSystemImpl

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);
}
Also used : NetworkSystem(org.terasology.network.NetworkSystem) EngineTime(org.terasology.engine.EngineTime) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl)

Example 3 with NetworkSystemImpl

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;
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) NetworkSystem(org.terasology.network.NetworkSystem) EntityRef(org.terasology.entitySystem.entity.EntityRef) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl)

Example 4 with NetworkSystemImpl

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();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) EntityRef(org.terasology.entitySystem.entity.EntityRef) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) Test(org.junit.Test)

Example 5 with NetworkSystemImpl

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();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) Test(org.junit.Test)

Aggregations

NetworkSystemImpl (org.terasology.network.internal.NetworkSystemImpl)6 EngineTime (org.terasology.engine.EngineTime)4 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)3 Test (org.junit.Test)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 EventLibrary (org.terasology.entitySystem.metadata.EventLibrary)2 NetworkSystem (org.terasology.network.NetworkSystem)2 Path (java.nio.file.Path)1 Before (org.junit.Before)1 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)1 LoadPrefabs (org.terasology.engine.modes.loadProcesses.LoadPrefabs)1 Game (org.terasology.game.Game)1 ConsoleImpl (org.terasology.logic.console.ConsoleImpl)1 LocalPlayer (org.terasology.logic.players.LocalPlayer)1 ReadWriteStorageManager (org.terasology.persistence.internal.ReadWriteStorageManager)1 BiomeManager (org.terasology.world.biomes.BiomeManager)1 BlockManager (org.terasology.world.block.BlockManager)1