client-side disconnect handling

pull/34/head
Zlatin Balevsky 2019-11-11 13:31:00 +00:00
parent 5e7f3587df
commit 29b5c55328
3 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.muwire.core
import java.nio.charset.StandardCharsets
import java.util.concurrent.atomic.AtomicBoolean
import com.muwire.core.chat.ChatDisconnectionEvent
import com.muwire.core.chat.ChatManager
import com.muwire.core.chat.ChatMessageEvent
import com.muwire.core.chat.ChatServer
@ -319,6 +320,7 @@ public class Core {
register(UIConnectChatEvent.class, chatManager)
register(UIDisconnectChatEvent.class, chatManager)
register(ChatMessageEvent.class, chatManager)
register(ChatDisconnectionEvent.class, chatManager)
}
log.info("initializing acceptor")

View File

@ -100,6 +100,11 @@ class ChatClient implements Closeable {
}
}
void disconnected() {
connectInProgress = false
connection = null
}
@Override
public void close() {
connectThread?.interrupt()

View File

@ -51,6 +51,10 @@ class ChatManager {
clients[e.host]?.connection?.sendChat(e)
}
void onChatDisconnectionEvent(ChatDisconnectionEvent e) {
clients[e.persona]?.disconnected()
}
private void connect() {
clients.each { k, v -> v.connectIfNeeded() }
}