From 0e26f5afd76808b6479bbdb7fdfec6d5f08025a8 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 14 Nov 2019 02:40:22 +0000 Subject: [PATCH] rejoin rooms on reconnect --- .../com/muwire/gui/ChatRoomController.groovy | 20 +++++++++++++++++++ .../com/muwire/gui/ChatServerModel.groovy | 20 ++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/ChatRoomController.groovy b/gui/griffon-app/controllers/com/muwire/gui/ChatRoomController.groovy index a0ca2dae..eb53546c 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/ChatRoomController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/ChatRoomController.groovy @@ -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) + } } \ No newline at end of file diff --git a/gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy b/gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy index 974f2cb6..71250a93 100644 --- a/gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/ChatServerModel.groovy @@ -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() {