當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。