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


Java Connection.close方法代碼示例

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


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

示例1: received

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
@Override
public void received (final Connection connection, Object object) {
	if(!(object instanceof Packet))
		return;
	Packet packet = ((Packet)object);

	if (packet instanceof Packet.LoginRequest)
		if (layer.net.lobby.checkPassword(((Packet.LoginRequest)packet).password)) {
			Debug.logDebug(LOG_TAG, "Authentification of " + connection.getRemoteAddressTCP() + " successful as: "
				+ ((Packet.LoginRequest)packet).username);

			trustedConnections.add(connection.getID());

			Packet.LoginAnswer answer = new Packet.LoginAnswer();
			answer.id = layer.net.lobby.players.size;
			layer.net.lobby.playerJoined(connection, ((Packet.LoginRequest)packet).username).send(answer, true);

			HookApi.postHooks(layer.net.lobby.onJoinedHooks, layer.net.lobby.getPlayerForConnection(connection));
		} else {
			Debug.log(LOG_TAG, "Authentification failed for " + connection.getRemoteAddressTCP());
			connection.close();
		}
	if (trustedConnections.contains(connection.getID()))
		layer.recieve(packet);
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:26,代碼來源:ServerListener.java

示例2: connected

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
@Override
public void connected(Connection connection) {
	if(this.connection == null) { //Only one client is allowed to connect at a time - connection gets set to null when disconnected gets called.
		try {
			this.connection = connection;
			connection.sendTCP(SensorMessages.createStatusMessage("Connected to Endpoint. Sensor: " + sensor + ".Connection from " + connection));
		} catch (PortException e) {
			connection.close();
			e.printStackTrace();
			throw new RuntimeException("Sensor port already in use.");
		}
	}
}
 
開發者ID:Echtzeitsysteme,項目名稱:mindroid,代碼行數:14,代碼來源:SensorEndpoint.java

示例3: connected

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
@Override
public void connected(Connection connection) {
	try {
		conn = connection;
	} catch (PortException e) {
		connection.close();
		e.printStackTrace();
		throw new RuntimeException("Motor port " + motor.getMotorPort().getName() + " already in use.");
	}
}
 
開發者ID:Echtzeitsysteme,項目名稱:mindroid,代碼行數:11,代碼來源:MotorEndpoint.java

示例4: handlePacket

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
public void handlePacket(Connection connection, Object packet) {
	if(packet instanceof Packet01LoginAnswer) {
		if(((Packet01LoginAnswer)packet).accepted) {
			System.out.println("Login authenticated.");
		} else {
			connection.close();
		}
	} else if(packet instanceof Packet02Message) {
		System.out.println(((Packet02Message)packet).message);
	}
}
 
開發者ID:CameronPersonett,項目名稱:NetworkChatApplication,代碼行數:12,代碼來源:ChatClient.java

示例5: handleNewTeamName

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
/**
 *
 * @param c a connected client
 * @param teamName
 */
private void handleNewTeamName(Connection c, String teamName) {
    List<String> teamNames = connectedTeams.values().stream().collect(Collectors.toList());

    if ( teamNames.contains(teamName) ) {
        c.sendTCP(Message.BAD_TEAMNAME);
        c.close();
    } else {
        connectedTeams.put(c, teamName);
        c.sendTCP(Message.GOOD_TEAMNAME);
    }
}
 
開發者ID:cthit,項目名稱:CodeIT,代碼行數:17,代碼來源:ServerController.java

示例6: handle

import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
@Override
public void handle(Connection connection, DisconnectPacket packet)
{
	connection.close();
}
 
開發者ID:MMORPG-Prototype,項目名稱:MMORPG_Prototype,代碼行數:6,代碼來源:DisconnectPacketHandler.java


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