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


Java Client.addListener方法代码示例

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


在下文中一共展示了Client.addListener方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: PlayerClient

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
public PlayerClient() {
	super();
	_players = new HashMap<Integer, Player>();
	_cars = new HashMap<Byte, Byte>();
	_player = new Player();
	_listenerList = new PlayerClientListenerList();
	_connected = false;
	
	_client = new Client();
	_client.start();
	PlayerServerClient serverClient = new PlayerServerClient(_client);
	PlayerNetwork.register(_client);
	_client.addListener(serverClient);
	_client.addListener(this);
	setPlayerServer(serverClient);
}
 
开发者ID:lumannnn,项目名称:AudioRacer,代码行数:17,代码来源:PlayerClient.java

示例10: 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:Imarcus,项目名称:OctoUML,代码行数:29,代码来源:ClientController.java

示例11: get

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
@Override
public Client get() {
    Client client = new Client();
    clientKryoListener.setClient(client);
    client.start();
    ChatUtil.registerClasses(client);
    client.addListener(clientKryoListener);
    return client;
}
 
开发者ID:aalmiray,项目名称:javatrove,代码行数:10,代码来源:ClientProvider.java

示例12: initialize

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
public void initialize() {
	username = JOptionPane.showInputDialog("Please enter a username.");
	client = new Client(25566, 25567);
	register();
	ClientListener listener = new ClientListener(this);
	client.addListener(listener);
	client.start();
}
 
开发者ID:CameronPersonett,项目名称:NetworkChatApplication,代码行数:9,代码来源:ChatClient.java

示例13: KryonetTransportLayer

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
public KryonetTransportLayer (RavNetwork net) {
	super(net);
	server = new Server(bufferSize, bufferSize);
	client = new Client(bufferSize, bufferSize);

	serverListener = new ServerListener(this);
	clientListener = new ClientListener(this);

	server.addListener(serverListener);
	client.addListener(clientListener);

	register(server.getKryo());
	register(client.getKryo());
	register(streamKryo);
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:16,代码来源:KryonetTransportLayer.java

示例14: setup

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
/**
 * Should be called when this scene is created, handles setup tasks.
 * @param stage The stage that this scene belongs to.
 * @param client The client that has an open connection to the server.
 * @param teamName The team name that the player has chosen.
 */
public void setup(Stage stage, Client client, String teamName) {
    this.stage = stage;
    this.client = client;
    this.team_name.setText(teamName);
    client.addListener(this);

    stage.setOnCloseRequest(event -> savePreferences());

    setServerStatus("Connected to " + client.getRemoteAddressTCP(), Color.GREEN);
    reconnect.setVisible(false);

    file_path.setText(preferences.get("file_path", System.getProperty("user.home")));
}
 
开发者ID:cthit,项目名称:CodeIT,代码行数:20,代码来源:ClientController.java

示例15: initNetwork

import com.esotericsoftware.kryonet.Client; //导入方法依赖的package包/类
public void initNetwork() {
    client = new Client(Network.BUFFER_SIZE, Network.BUFFER_SIZE);

    Initializer.registerClasses(client.getKryo());
    client.addListener(this);
    clientThread = new Thread(client);
    clientThread.start();
}
 
开发者ID:cthit,项目名称:CodeIT,代码行数:9,代码来源:LoginController.java


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