当前位置: 首页>>代码示例>>Java>>正文


Java Client类代码示例

本文整理汇总了Java中com.esotericsoftware.kryonet.Client的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Client类属于com.esotericsoftware.kryonet包,在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EV3Brick

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
/**
 * Creates a Brick Class.
 *
 * @param ev3Brick_IP
 * @param ev3Brick_PORT
    */
public EV3Brick (final String ev3Brick_IP, int ev3Brick_PORT) {
       this.EV3Brick_IP = ev3Brick_IP;
       this.EV3Brick_PORT = ev3Brick_PORT;
       
       motorManager 	= new EV3MotorManager(this); //TODO
       sensorManager 	= new EV3SensorManager(this);

	System.out.println("Local-EV3Brick: Starte client.. ");
	client = new Client();
	client.start();
	new Thread(client).start(); //Neccessary to keep connection alive!

	/** Add Listeners to Client **/
	client.addListener(this);
	client.addListener(sensorManager);
	client.addListener(motorManager);

	//Set Client to Motor-/Sensormanager
	sensorManager.setBrickClient(client);
	motorManager.setBrickClient(client);

	MessageRegistrar.register(client);


   }
 
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:32,代码来源:EV3Brick.java

示例2: addReceiver

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
/**
 * Makes this chat client process and respond to audio sent from the server. If this message is not called, you will not hear anything
 * from the server!
 * @param client The client that audio data will be sent to from the server. Just use the normal client.
 */
public void addReceiver(Client client){
	
	if(this.player == null)
		this.createPlayer();
	
	client.addListener(new Listener(){
		public void received(Connection connection, Object object) {
			
			// Only read objects of the correct type.
			if(object instanceof VoiceNetData){
				
				// Read data
				VoiceNetData message = (VoiceNetData)object;					
				short[] data = message.getData();
				
				// Play audio
				processAudio(data, connection, message);
			}
		}			
	});
}
 
开发者ID:Epicguru,项目名称:VoiceChat,代码行数:27,代码来源:VoiceChatClient.java

示例3: ClientController

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public ClientController(AbstractDiagramController pDiagramController, String pServerIp, int pPort) {
    diagramController = pDiagramController;
    serverIp = pServerIp;
    port = pPort;

    client = new Client();

    initKryo(client.getKryo());

    client.addListener(new Listener() {
        public void received (Connection connection, Object object) {
            if (object instanceof AbstractNode) {
                Platform.runLater(() -> diagramController.createNodeView((AbstractNode)object, true));
            } else if (object instanceof AbstractEdge) {
                Platform.runLater(() -> diagramController.addEdgeView((AbstractEdge)object, true));
            } else if (object instanceof Graph){
                Graph graph = (Graph) object;
                graph.addRemotePropertyChangeListener(ClientController.this);
                Platform.runLater(() -> diagramController.load(graph, true));
            } else if (object instanceof String[]){
                Platform.runLater(() -> diagramController.remoteCommand((String[])object));
            }
        }
    });
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:26,代码来源:ClientController.java

示例4: handle

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
@Override
public void handle(final Client client, Connection connection, Command command) {
    model.getClient().ifPresent(c -> {
        if (c == client) {
            model.getMessages().add("Server " + model.getServer() + ":" + model.getPort() + " is no longer available.");
            client.stop();
            try {
                client.dispose();
            } catch (IOException ignored) {
                // OK
            }
            model.setClient(null);
            model.setConnected(false);
            model.getMessages().clear();
        }
    });
}
 
开发者ID:aalmiray,项目名称:javatrove,代码行数:18,代码来源:ClientDisconnectCommandHandler.java

示例5: ClientNetworkController

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public ClientNetworkController() {
	while (true) {
		promptIPPort();
		client = new Client();
		client.start();
		try {
			client.connect(5000, Variables.serverIP, Variables.port);
		}
		catch (IOException e) {
			Utilities.popupMessage("BuildStation", "Invalid Input\nThe server refused the connection or an unknown error occurred.");
			e.printStackTrace();
			promptIPPort();
			continue;
		}
		client.getKryo().setRegistrationRequired(false);
		ListenerList.addListeners(client);
		break;
	}
}
 
开发者ID:Ameliorate,项目名称:Buildstation-3,代码行数:20,代码来源:ClientNetworkController.java

示例6: PacketsInterpretator

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public PacketsInterpretator(Client client) {
    mClient = client;
    mPackets.put(ConnectPacket.class, new ConnectAction());
    mPackets.put(ErrorPacket.class, new ErrorAction());
    mPackets.put(EntityPacket.class, new EntityAction());
    mPackets.put(EntityMovePacket.class, new EntityMoveAction());
    mPackets.put(EntityRemovePacket.class, new EntityRemoveAction());
    mPackets.put(EntityHpPacket.class, new EntityHpAction());
    mPackets.put(EntityEffectAddPacket.class, new EntityEffectAddAction());
    mPackets.put(EntityEffectRemovePacket.class, new EntityEffectRemoveAction());
    mPackets.put(NewUserConnectedLobbyPacket.class, new NewUserConnectedLobbyAction());
    mPackets.put(TchatMsgPacket.class, new TchatMsgAction());
    mPackets.put(TchatPrivmsgPacket.class, new TchatPrivmsgAction());
    mPackets.put(PlayerSpellPacket.class, new PlayerSpellAction());
    mPackets.put(PlayerSpellUsedPacket.class, new PlayerSpellUsedAction());
}
 
开发者ID:AlexMog,项目名称:MMO-Rulemasters-World,代码行数:17,代码来源:PacketsInterpretator.java

示例7: StateProcessor

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public StateProcessor(Client client, ConcurrentHashMap<Short, ClientEntity> worldMap,
        SFXPlayer audioPlayer, PlatformServices toaster) {
    if (client != null) {
        this.client = client;
        client.addListener(this);
    }
    this.toaster = toaster;
    
    nextState = MessageObjectPool.instance.
            gameStateMessagePool.obtain();
    nextState.time = 0;
    stateQueue = new ArrayList<GameStateMessage>();
    wait = new AtomicBoolean(false);
    this.world = worldMap;
    disconnected = false;
    this.audioPlayer = audioPlayer;
    playerNames = new PlayerNamesMessage();
}
 
开发者ID:ganeshkamathp,项目名称:killingspree,代码行数:19,代码来源:StateProcessor.java

示例8: WorldRenderer

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public WorldRenderer(WorldManager worldManager, Client client, KillingSpree game) {
    worldMap = new ConcurrentHashMap<Short, ClientEntity>();
    this.worldManager = worldManager;
    audioPlayer = new SFXPlayer();
    stateProcessor = new StateProcessor(client, worldMap, audioPlayer,
            game.platformServices);
    if (worldManager != null) {
        debugRenderer = new WorldDebugRenderer(worldManager.getWorld());
        worldManager.setOutgoingEventListener(stateProcessor);
    } else {
        this.client = client;
    }
    camera = new OrthographicCamera();
    batch = new SpriteBatch();
    controlsSender = new ControlsSender();
    recentId = -2;
    screenShakeX = 0;
    screenShakeY = 0;
    screenShakeTime = 0;
    hudRenderer = new HUDRenderer();
    this.game = game;
}
 
开发者ID:ganeshkamathp,项目名称:killingspree,代码行数:23,代码来源:WorldRenderer.java

示例9: show

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
@Override
public void show() {
    client = new Client();
    client.start();
    font = game.getFont(120);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
    buttons = new ArrayList<MyButton>();
    ipAddresses = new ArrayList<MyButton>();
    markForDispose = false;
    addAllButtons();
    addIpButtons();
    pressedButton = false;
}
 
开发者ID:ganeshkamathp,项目名称:killingspree,代码行数:17,代码来源:ClientDiscoveryScreen.java

示例10: loadLevel

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public boolean loadLevel(String level, String host, String name) {
    if (isServer) {
        world = new WorldManager(server);
        if (server == null)
            world.loader.platformServices = game.platformServices;
    } else {
        client = new Client();
        NetworkRegisterer.register(client);
        client.start();
        try {
            client.connect(Constants.TIMEOUT, host,
                    Constants.GAME_TCP_PORT,
                    Constants.GAME_UDP_PORT);
        } catch (IOException e) {
            game.platformServices.toast("Server not found");
            e.printStackTrace();
            game.setScreen(new ClientDiscoveryScreen(game));
            return false;
        }
    }
    
    renderer = new WorldRenderer(world, client, game);
    renderer.loadLevel(level, isServer, name);
    return true;
}
 
开发者ID:ganeshkamathp,项目名称:killingspree,代码行数:26,代码来源:GameScreen.java

示例11: launchClient

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
@Override
public synchronized boolean launchClient()
{	boolean result = true;

	client = new Client(60000, 60000);
	client.start();

	firstRound = true;

	ClassRegisterer.register(client);

	client.addListener(this);

	int timeout = 5000;
	try
	{	client.connect(timeout, ip, port, port + 1);
	}
	catch (IOException e)
	{	result = false;
		e.printStackTrace();
	}

	return result;
}
 
开发者ID:CeriAvignon,项目名称:Projet2015,代码行数:25,代码来源:ClientCommunicationKryonetImpl.java

示例12: move

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
@Override
public void move(Entity item, int x, int y) {
	
	ArrayList<ItemContainerGroup> groups = getGroups(item, x, y);
	ItemContainerGroup group = null;
	if (groups.size() > 0) {
		group = groups.get(0);			
	} else { return; }
	
	x = (int) (((x-getX())/RenderingSystem.scale)/SLOTSIZE);
	y = (int) (((y-getY())/RenderingSystem.scale)/SLOTSIZE);
	
	if (group instanceof InventoryGUI) {
		MoveItemSimple action = new MoveItemSimple();
		action.setID(item.getComponent(CId.class));
		action.setXY(x, y);
		((Client)AppUtil.endpoint).sendTCP(action);
	}
}
 
开发者ID:Teascade,项目名称:Shadow-of-Goritur,代码行数:20,代码来源:InventoryGUI.java

示例13: PeaceNetworkClient

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public PeaceNetworkClient()
{
	client = new Client();
	
	events = (Queue<PacketMessage>) new LinkedList<PacketMessage>();
	
	// Must register every class that will be sent/received
	client.getKryo().register(PacketMessage.class);
	client.getKryo().register(EventType.class);
	client.getKryo().register(LocationID.class);
	
	// Client must start before connecting can take place
	client.start();
	
	client.addListener(this);
	
	out.println("Client is now waiting..."); // TODO: remove
}
 
开发者ID:SheldonSandbekkhaug,项目名称:Peace,代码行数:19,代码来源:PeaceNetworkClient.java

示例14: NetClient

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public NetClient(InvadersGame game, GameSetupConfig gameSetupConfig, PlayerConfig player) {
    this.game = game;
    gameConfig = gameSetupConfig;
    this.playerConfig = player;
    listeners = new Array<NetListener>();

    client = new Client();
    client.start();

    KryoCommon.register(client);

    currentListener = new ConnectListener(this);
    client.addListener(currentListener);

    connect();
}
 
开发者ID:fbcouch,项目名称:ahs-invaders,代码行数:17,代码来源:NetClient.java

示例15: FSUIPCKryonetInterface

import com.esotericsoftware.kryonet.Client; //导入依赖的package包/类
public FSUIPCKryonetInterface(String server, int port) {
    this.server = server;
    this.port = port;
    // ~
    client = new Client();
    client.start();
    client.addListener(new Listener() {
        public void received (Connection connection, Object object) {
            if(object instanceof String) {
                String message = (String)object;
                if(message.startsWith("CHANGED")) {
                    Collection<OffsetItem> offsetItems = toOffsetItems(message);
                    for(OffsetItem offsetItem : offsetItems) {
                        offsetEventListeners.fire().valueChanged(offsetItem);
                    }
                    offsetCollectionEventListeners.fire().valuesChanged(offsetItems);
                }
            }
        }
    });
    // ~
    offsetEventListeners = EventListenerSupport.create(OffsetEventListener.class);
    offsetCollectionEventListeners = EventListenerSupport.create(OffsetCollectionEventListener.class);
}
 
开发者ID:RBernhardt,项目名称:homecockpit-fsuipc,代码行数:25,代码来源:FSUIPCKryonetInterface.java


注:本文中的com.esotericsoftware.kryonet.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。