rejoin rooms on reconnect
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
@@ -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() {
|
||||||
|
Reference in New Issue
Block a user