send periodic pings
This commit is contained in:
@@ -110,4 +110,8 @@ class ChatClient implements Closeable {
|
||||
connectThread?.interrupt()
|
||||
connection?.close()
|
||||
}
|
||||
|
||||
void ping() {
|
||||
connection?.sendPing()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,10 @@ class ChatManager {
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
clients.each { k, v -> v.connectIfNeeded() }
|
||||
clients.each { k, v ->
|
||||
v.connectIfNeeded()
|
||||
v.ping()
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
|
||||
@@ -39,12 +39,21 @@ class ChatServer {
|
||||
this.settings = settings
|
||||
this.trustService = trustService
|
||||
this.me = me
|
||||
|
||||
Timer timer = new Timer("chat-server-pinger", true)
|
||||
timer.schedule({sendPings()} as TimerTask, 1000, 1000)
|
||||
}
|
||||
|
||||
public void start() {
|
||||
running.set(true)
|
||||
}
|
||||
|
||||
private void sendPings() {
|
||||
connections.each { k,v ->
|
||||
v.sendPing()
|
||||
}
|
||||
}
|
||||
|
||||
public void handle(Endpoint endpoint) {
|
||||
InputStream is = endpoint.getInputStream()
|
||||
OutputStream os = endpoint.getOutputStream()
|
||||
|
||||
Reference in New Issue
Block a user