/** * ( begin auto-generated from Server_disconnect.xml ) * * <p>Disconnect a particular client. * * <p>( end auto-generated ) * * @brief Disconnect a particular client. * @webref server:server * @param client the client to disconnect */ public void disconnect(Client client) { client.stop(); int index = clientIndex(client); if (index != -1) { removeIndex(index); } }
public static void main(String[] args) throws Exception { BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in)); Client c = new BaseClient(); int connected = c.connect(Constants.HOSTNAME, Constants.PORT); if (connected != 0) { exitApp(); } String msg; do { c.doLogin(); } while (c.isConnected() && !c.isLoggedIn()); while (c.isConnected()) { msg = inReader.readLine(); if (!StringUtils.isBlank(msg)) { if (Utils.matchesClinetCommonCommandPattern(msg)) { // сообщение содержит комманду c.sendRawText(msg); } else { c.send(msg); } } } c.stop(); exitApp(); }
/** * Stop a RPC client connection A RPC client is closed only when its reference count becomes * zero. */ private void stopClient(Client client) { synchronized (this) { client.decCount(); if (client.isZeroReference()) { clients.remove(client.getSocketFactory()); } } if (client.isZeroReference()) { client.stop(); } }
/** end the game but not yet exit, still stay in the game activity */ public static void endGame() { Client.deactivate(); Server.stop(); Client.stop(); ClientGameState.clear(); if (BallCraft.isServer) { ServerGameState.clear(); } GameRenderer.stopRendering(); ServerAdapter.stopBTService(); Intent intent = new Intent(self, EndGameMenu.class); intent.putExtra("selfScore", selfScore); intent.putExtra("enemyScore", enemyScore); self.startActivity(intent); self.finish(); self.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }