rejoin rooms on reconnect

This commit is contained in:
Zlatin Balevsky
2019-11-14 02:40:22 +00:00
parent 114bc06dbb
commit 0e26f5afd7
2 changed files with 31 additions and 9 deletions

View File

@@ -233,4 +233,24 @@ class ChatRoomController {
view.roomTextArea.replaceRange(null, line0Start, line0End)
}
}
void rejoinRoom() {
if (model.room == ChatServer.CONSOLE)
return
UUID uuid = UUID.randomUUID()
long now = System.currentTimeMillis()
String join = "/JOIN $model.room"
byte [] sig = ChatConnection.sign(uuid, now, model.room, join, model.core.me, model.host, model.core.spk)
def event = new ChatMessageEvent(
uuid : uuid,
payload : join,
sender : model.core.me,
host : model.host,
room : model.room,
chatTime : now,
sig : sig
)
model.core.eventBus.publish(event)
}
}

View File

@@ -50,19 +50,21 @@ class ChatServerModel {
}
void onChatConnectionEvent(ChatConnectionEvent e) {
if (e.persona == host) {
runInsideUIAsync {
status = e.status
}
if (e.persona != host)
return
runInsideUIAsync {
status = e.status
}
ChatLink link = e.connection
if (link == null)
return
if (link.getPersona() == host)
this.link = link
else if (link.getPersona() == null && host == core.me)
this.link = link
this.link = e.connection
mvcGroup.childrenGroups.each {k,v ->
v.controller.rejoinRoom()
}
}
private void eventLoop() {