本文整理匯總了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);
}
示例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);
}
}
});
}
示例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));
}
}
});
}
示例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();
}
示例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;
}
示例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
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
}
});
}
示例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;
}
示例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();
}
示例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);
}
示例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")));
}
示例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();
}