當前位置: 首頁>>代碼示例>>Java>>正文


Java Listener類代碼示例

本文整理匯總了Java中com.esotericsoftware.kryonet.Listener的典型用法代碼示例。如果您正苦於以下問題:Java Listener類的具體用法?Java Listener怎麽用?Java Listener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Listener類屬於com.esotericsoftware.kryonet包,在下文中一共展示了Listener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LoginScreen

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
public LoginScreen(CatanGame pGame) {
    aGame = pGame;
    listener = new Listener() {
        @Override
        public void received(Connection connection, Object object) {
            if (object instanceof LoginResponse) {
                Gdx.app.postRunnable(() -> {
                    // Handle the login response from the server
                    if (((LoginResponse) object).success) {
                        // Cache the account used to login successfully
                        AccountManager.writeLocalAccount(account);
                        CatanGame.account = account;
                        // Move on to the main screen
                        aGame.switchScreen(ScreenKind.MAIN_MENU);
                    } else {
                        errorMessageLabel.setText(ERROR_USERNAME);
                    }
                });
            }
        }
    };
}
 
開發者ID:teobaranga,項目名稱:Catan,代碼行數:23,代碼來源:LoginScreen.java

示例2: show

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
@Override
public void show() {
    super.show();

    entities = new HashMap<Integer, EntityPacket.EntityRender>();

    game.getClient().sendTCP(new ViewShare("696969"));

    game.getClient().addListener(new Listener() {
        @Override
        public void received(Connection connection, Object o) {
            if(o instanceof EntityPacket)
                Gdx.app.log("Entities", "Session" + ((EntityPacket) o).session);
        }
    });
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:17,代碼來源:SpectateScreen.java

示例3: addReceiver

import com.esotericsoftware.kryonet.Listener; //導入依賴的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

示例4: ClientController

import com.esotericsoftware.kryonet.Listener; //導入依賴的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

示例5: connect

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
public boolean connect(NetworkServerConfig config) {
    try {
        this.client.connect(5000, config.getAddress(), config.getTcpPort(), config.getUdpPort());
        this.client.addListener(new Listener() {
            public void received(Connection connection, Object object) {
                if (object instanceof MessageModel) {
                    MessageModel response = (MessageModel) object;
                    masterTask.sendTask(TaskFactory.createTask(EnumTargetTask.MESSAGE_SERVER, EnumTargetTask.GAME, response));
                }
            }
        });
        this.masterTask.sendTask(TaskFactory.createTask(EnumTargetTask.MESSAGE_SERVER, EnumTargetTask.ACCOUNT, EnumWindow.INTERFACE));
        return true;
    } catch (IOException e) {
        System.err.println("ERROR: " + e.getMessage());
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:LeNiglo,項目名稱:TinyTank,代碼行數:20,代碼來源:NetworkController.java

示例6: NetworkServerImpl

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
public NetworkServerImpl(final NetworkConfigurationData configuration) {
  Validate.notNull(configuration);
  this.configuration = configuration;
  ObjectSpace _objectSpace = new ObjectSpace();
  this.objectSpace = _objectSpace;
  MyServer _myServer = new MyServer(this.objectSpace);
  this.server = _myServer;
  Kryo _kryo = this.server.getKryo();
  ObjectSpace.registerClasses(_kryo);
  Kryo _kryo_1 = this.server.getKryo();
  SerializerHelper.initializeKryo(_kryo_1);
  this.sentBytes = 0L;
  long _currentTimeMillis = System.currentTimeMillis();
  this.lastLog = _currentTimeMillis;
  MyHashMap<Integer, NetworkService> _myHashMap = new MyHashMap<Integer, NetworkService>();
  this.serviceMap = _myHashMap;
  HashSet<Listener> _newHashSet = CollectionLiterals.<Listener>newHashSet();
  this.listeners = _newHashSet;
}
 
開發者ID:CymricNPG,項目名稱:abattle,代碼行數:20,代碼來源:NetworkServerImpl.java

示例7: getEventsForPeriod

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
public void getEventsForPeriod(LocalDate from, LocalDate to, ObservableList<Event> observableEvents) {
    EventMessage eventMessage = new EventMessage(currentUser.getValue(), EventMessage.Command.SEND_EVENTS, from, to);
    CalendarClient client = CalendarClient.getInstance();

    Listener listener = new Listener() {
        public void received(Connection connection, Object object) {
            if (object instanceof EventMessage) {
                EventMessage message = (EventMessage) object;
                if (message.getCommand() == EventMessage.Command.RECEIVE_EVENTS) {
                    observableEvents.addAll(message.getEvents());
                    client.removeListener(this);
                }
            }
        }
    };

    client.addListener(listener);
    client.sendMessage(eventMessage);
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:20,代碼來源:CalendarController.java

示例8: getAllTeams

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
private void getAllTeams() {
    TeamMessage message = new TeamMessage(TeamMessage.Command.SEND_TEAMS);
    CalendarClient client = CalendarClient.getInstance();

    Listener getTeamsListener = new Listener() {
        public void received(Connection connection, Object object) {
            if (object instanceof TeamMessage) {
                TeamMessage complete = (TeamMessage) object;
                switch (complete.getCommand()) {
                    case RECEIVE_TEAMS:
                        setAllTeams(complete.getTeams());
                        break;
                    case SEND_TEAMS:
                        break;
                }
                client.removeListener(this);
            }
        }

    };
    client.addListener(getTeamsListener);
    client.sendMessage(message);
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:24,代碼來源:CreateEventController.java

示例9: getInvited

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
private void getInvited(int id) {
    RequestMessage message = new RequestMessage(RequestMessage.Command.INVITED_USERS_REQUEST, id);

    CalendarClient client = CalendarClient.getInstance();

    Listener getInvitedListener = new Listener() {
        public void received(Connection connection, Object object) {
            if (object instanceof ParticipantUserMessage) {
                ParticipantUserMessage complete = (ParticipantUserMessage) object;
                switch (complete.getCommand()) {
                    case RECEIVE_ALL:
                        setInvited(complete.getParticipantUsers());
                        break;
                    case SEND_ALL:
                        break;
                }
                client.removeListener(this);
            }
        }
    };
    client.addListener(getInvitedListener);
    client.sendMessage(message);
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:24,代碼來源:CreateEventController.java

示例10: findUsers

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
public void findUsers() {
    UserMessage userMessage = new UserMessage(UserMessage.Command.SEND_ALL);
    CalendarClient client = CalendarClient.getInstance();

    Listener listener = new Listener() {
        public void received(Connection connection, Object object) {
            if (object instanceof UserMessage) {
                UserMessage message = (UserMessage) object;
                if (message.getCommand() == UserMessage.Command.RECEIVE_ALL) {
                    users.addAll(message.getUsers());
                    allUsers.addAll(message.getUsers());
                    client.removeListener(this);
                }
            }
        }
    };

    client.addListener(listener);
    client.sendMessage(userMessage);
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:21,代碼來源:ChooseCalendarComboBox.java

示例11: listenForNotifications

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
private void listenForNotifications() {
    NotificationMessage findNotifications = new NotificationMessage(
            NotificationMessage.Command.GETALL_NOTIFICATIONS);

    CalendarClient client = CalendarClient.getInstance();

    Listener listener = new Listener() {
        public void received(Connection connection, Object object) {
            if (object instanceof NotificationMessage) {
                NotificationMessage message = (NotificationMessage) object;

                switch (message.getCommand()) {
                    case RECEIVE_NOTIFICATION:
                        Platform.runLater(() -> notifications.addAll(0, message.getNotifications()));
                        break;
                }
            }
        }
    };

    client.addListener(listener);
    client.sendMessage(findNotifications);
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:24,代碼來源:NotificationList.java

示例12: FSUIPCKryonetInterface

import com.esotericsoftware.kryonet.Listener; //導入依賴的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

示例13: startLobby

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
private String[] startLobby(){
    final Menu menu = new Menu("lobby");
    client.getClient().addListener(new Listener() {
        public void received (Connection connection, Object object) {
            if (object instanceof Network.Start) {
                menu.action = "continue";
                return;
            }
        }
    });
    client.sendReady();
    String[] menuReturn;
    do {
         menuReturn = menu.render();
        if(menuReturn[0].equals("forceStart")){
            client.sendForceStart();
            client.sendReady();
        }
    }while (!menuReturn[0].equals("continue"));

    return menuReturn;
}
 
開發者ID:Lord-Nazdar,項目名稱:Conquest,代碼行數:23,代碼來源:Conquest.java

示例14: create

import com.esotericsoftware.kryonet.Listener; //導入依賴的package包/類
@Override
public void create() {
	try{
		
		if(true){
			// Run server
			this.server = new Server(22050, 22050);
			server.bind(7777, 7777);
			server.start();	
			
			relay = new VoiceChatServer(server.getKryo());
			
			server.addListener(new Listener(){
				public void received(Connection connection, Object object) {
					relay.relayVoice(connection, object, server);
				}					
			});
		}

		this.client = new Client(22050, 22050);
		client.start();
		client.connect(5000, "localhost", 7777, 7777);
		
		this.sender = new VoiceChatClient(client.getKryo());
		this.sender.addReceiver(client);
		
		
	}catch(Exception e){
		e.printStackTrace();
		Gdx.app.exit();
	}	
	
	
	// Other stuff for test
	batch = new SpriteBatch();
	font = new BitmapFont();
}
 
開發者ID:Epicguru,項目名稱:VoiceChat,代碼行數:38,代碼來源:TestGame.java

示例15: ClientController

import com.esotericsoftware.kryonet.Listener; //導入依賴的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


注:本文中的com.esotericsoftware.kryonet.Listener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。