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) 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) { void onChatConnectionEvent(ChatConnectionEvent e) {
if (e.persona == host) { if (e.persona != host)
runInsideUIAsync { return
status = e.status
} runInsideUIAsync {
status = e.status
} }
ChatLink link = e.connection ChatLink link = e.connection
if (link == null) if (link == null)
return return
if (link.getPersona() == host) this.link = e.connection
this.link = link
else if (link.getPersona() == null && host == core.me) mvcGroup.childrenGroups.each {k,v ->
this.link = link v.controller.rejoinRoom()
}
} }
private void eventLoop() { private void eventLoop() {