本文整理匯總了Java中com.esotericsoftware.kryonet.Client.start方法的典型用法代碼示例。如果您正苦於以下問題:Java Client.start方法的具體用法?Java Client.start怎麽用?Java Client.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.esotericsoftware.kryonet.Client
的用法示例。
在下文中一共展示了Client.start方法的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: 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;
}
}
示例3: 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;
}
示例4: 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;
}
示例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: ClientEndpointImpl
import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
public ClientEndpointImpl(String ip,int tcpPort, int brickTimeout) {
this.ip =ip;
this.tcpPort = tcpPort;
this.brickTimeout = brickTimeout;
client = new Client();
client.start();
new Thread(client).start();
}
示例11: ConnectionState
import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
public ConnectionState(Client client, StateManager states, ConnectionInfo connectionInfo)
{
this.client = client;
this.states = states;
client.start();
connectThread = new Thread(() -> tryConnecting(client, connectionInfo));
connectThread.start();
}
示例12: 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;
}
示例13: 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();
}
示例14: HeadlessClientNetworkController
import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
/**
* @throws IOException If the server refused the connection.
*/
public HeadlessClientNetworkController() throws IOException {
client = new Client();
client.start();
client.connect(5000, Variables.serverIP, Variables.port);
client.getKryo().setRegistrationRequired(false);
ListenerList.addListeners(client);
isHeadless = true; // I wish I could avoid this, but for some reason, I can't override promptIPPort.
}
示例15: setServer
import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
public void setServer(boolean isServer) {
this.isServer = isServer;
try {
if (isServer) {
server = new Server();
NetworkRegisterer.register(server);
serverListener = new LobbyServerListener();
server.addListener(serverListener);
server.start();
server.bind(Constants.DISCOVERY_TCP_PORT,
Constants.DISCOVERY_UDP_PORT);
// Thread.currentThread().sleep(200);
}
client = new Client();
NetworkRegisterer.register(client);
client.start();
clientListener = new LobbyClientListener();
client.addListener(clientListener);
client.connect(5000, host,
Constants.DISCOVERY_TCP_PORT,
Constants.DISCOVERY_UDP_PORT);
} catch (Exception e) {
currentButton = backButton;
markForDispose = true;
e.printStackTrace();
}
addAllButtons();
}