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