public void close() throws IOException { synchronized (this) { if (closed) return; connected = false; closed = true; if (notificationHandler != null) notificationHandler.stop(); if (heartbeat != null) heartbeat.stop(); if (connection != null) connection.close(); connection = null; rmiServer = null; } emitter.sendConnectionNotificationClosed(); }