public void close() { boolean wasConnected = isConnected; isConnected = false; tcp.close(); if (udp != null && udp.connectedAddress != null) udp.close(); if (wasConnected) { notifyDisconnected(); if (INFO) info("kryonet", this + " disconnected."); } setConnected(false); }
public void sendUdpOneWay(Message message, EndPoint to) { EndPoint from = message.getFrom(); if (message.getFrom().equals(to)) { MessagingService.receive(message); return; } UdpConnection connection = null; try { connection = new UdpConnection(); connection.init(); connection.write(message, to); } catch (IOException e) { logger_.warn(LogUtil.throwableToString(e)); } finally { if (connection != null) connection.close(); } }