shutdown chat components

pull/34/head
Zlatin Balevsky 2019-11-11 13:26:25 +00:00
parent 8afd387ca6
commit 5e7f3587df
2 changed files with 14 additions and 2 deletions

View File

@ -110,6 +110,8 @@ public class Core {
final UploadManager uploadManager final UploadManager uploadManager
final ContentManager contentManager final ContentManager contentManager
final CertificateManager certificateManager final CertificateManager certificateManager
final ChatServer chatServer
final ChatManager chatManager
private final Router router private final Router router
@ -308,11 +310,11 @@ public class Core {
connectionEstablisher = new ConnectionEstablisher(eventBus, i2pConnector, props, connectionManager, hostCache) connectionEstablisher = new ConnectionEstablisher(eventBus, i2pConnector, props, connectionManager, hostCache)
log.info("initializing chat server") 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) eventBus.register(ChatMessageEvent.class, chatServer)
log.info("initializing chat manager") log.info("initializing chat manager")
ChatManager chatManager = new ChatManager(eventBus, me, i2pConnector, trustService, props) chatManager = new ChatManager(eventBus, me, i2pConnector, trustService, props)
eventBus.with { eventBus.with {
register(UIConnectChatEvent.class, chatManager) register(UIConnectChatEvent.class, chatManager)
register(UIDisconnectChatEvent.class, chatManager) register(UIDisconnectChatEvent.class, chatManager)
@ -385,6 +387,10 @@ public class Core {
directoryWatcher.stop() directoryWatcher.stop()
log.info("shutting down cache client") log.info("shutting down cache client")
cacheClient.stop() cacheClient.stop()
log.info("shutting down chat server")
chatServer.shutdown()
log.info("shutting down chat manager")
chatManager.shutdown()
log.info("shutting down connection manager") log.info("shutting down connection manager")
connectionManager.shutdown() connectionManager.shutdown()
if (router != null) { if (router != null) {

View File

@ -170,4 +170,10 @@ class ChatServer {
connections[target.destination]?.sendChat(e) connections[target.destination]?.sendChat(e)
} }
} }
void shutdown() {
connections.each { k, v ->
v.close()
}
}
} }