本文整理匯總了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);
}
示例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.");
}
}
}
示例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.");
}
}
示例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);
}
}
示例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);
}
}
示例6: handle
import com.esotericsoftware.kryonet.Connection; //導入方法依賴的package包/類
@Override
public void handle(Connection connection, DisconnectPacket packet)
{
connection.close();
}