mirror of https://github.com/zlatinb/muwire
client-side disconnect handling
parent
5e7f3587df
commit
29b5c55328
|
@ -3,6 +3,7 @@ package com.muwire.core
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
|
||||||
|
import com.muwire.core.chat.ChatDisconnectionEvent
|
||||||
import com.muwire.core.chat.ChatManager
|
import com.muwire.core.chat.ChatManager
|
||||||
import com.muwire.core.chat.ChatMessageEvent
|
import com.muwire.core.chat.ChatMessageEvent
|
||||||
import com.muwire.core.chat.ChatServer
|
import com.muwire.core.chat.ChatServer
|
||||||
|
@ -319,6 +320,7 @@ public class Core {
|
||||||
register(UIConnectChatEvent.class, chatManager)
|
register(UIConnectChatEvent.class, chatManager)
|
||||||
register(UIDisconnectChatEvent.class, chatManager)
|
register(UIDisconnectChatEvent.class, chatManager)
|
||||||
register(ChatMessageEvent.class, chatManager)
|
register(ChatMessageEvent.class, chatManager)
|
||||||
|
register(ChatDisconnectionEvent.class, chatManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("initializing acceptor")
|
log.info("initializing acceptor")
|
||||||
|
|
|
@ -100,6 +100,11 @@ class ChatClient implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void disconnected() {
|
||||||
|
connectInProgress = false
|
||||||
|
connection = null
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
connectThread?.interrupt()
|
connectThread?.interrupt()
|
||||||
|
|
|
@ -51,6 +51,10 @@ class ChatManager {
|
||||||
clients[e.host]?.connection?.sendChat(e)
|
clients[e.host]?.connection?.sendChat(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onChatDisconnectionEvent(ChatDisconnectionEvent e) {
|
||||||
|
clients[e.persona]?.disconnected()
|
||||||
|
}
|
||||||
|
|
||||||
private void connect() {
|
private void connect() {
|
||||||
clients.each { k, v -> v.connectIfNeeded() }
|
clients.each { k, v -> v.connectIfNeeded() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue