diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 8e5e5999..6af42b42 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -110,6 +110,8 @@ public class Core { final UploadManager uploadManager final ContentManager contentManager final CertificateManager certificateManager + final ChatServer chatServer + final ChatManager chatManager private final Router router @@ -308,11 +310,11 @@ public class Core { connectionEstablisher = new ConnectionEstablisher(eventBus, i2pConnector, props, connectionManager, hostCache) log.info("initializing chat server") - ChatServer chatServer = new ChatServer(eventBus, props, trustService, me) + chatServer = new ChatServer(eventBus, props, trustService, me) eventBus.register(ChatMessageEvent.class, chatServer) log.info("initializing chat manager") - ChatManager chatManager = new ChatManager(eventBus, me, i2pConnector, trustService, props) + chatManager = new ChatManager(eventBus, me, i2pConnector, trustService, props) eventBus.with { register(UIConnectChatEvent.class, chatManager) register(UIDisconnectChatEvent.class, chatManager) @@ -385,6 +387,10 @@ public class Core { directoryWatcher.stop() log.info("shutting down cache client") cacheClient.stop() + log.info("shutting down chat server") + chatServer.shutdown() + log.info("shutting down chat manager") + chatManager.shutdown() log.info("shutting down connection manager") connectionManager.shutdown() if (router != null) { diff --git a/core/src/main/groovy/com/muwire/core/chat/ChatServer.groovy b/core/src/main/groovy/com/muwire/core/chat/ChatServer.groovy index 0795834c..bfa683b3 100644 --- a/core/src/main/groovy/com/muwire/core/chat/ChatServer.groovy +++ b/core/src/main/groovy/com/muwire/core/chat/ChatServer.groovy @@ -170,4 +170,10 @@ class ChatServer { connections[target.destination]?.sendChat(e) } } + + void shutdown() { + connections.each { k, v -> + v.close() + } + } }