wip on private messages

This commit is contained in:
Zlatin Balevsky
2019-11-12 13:16:36 +00:00
parent 59c03be35e
commit 1f9b171021
4 changed files with 10 additions and 6 deletions

View File

@@ -67,6 +67,7 @@ class ChatRoomController {
params['room'] = newRoom params['room'] = newRoom
params['console'] = false params['console'] = false
params['host'] = model.host params['host'] = model.host
params['roomTabName'] = newRoom
mvcGroup.parentGroup.createMVCGroup("chat-room", newRoom, params) mvcGroup.parentGroup.createMVCGroup("chat-room", newRoom, params)
} }
@@ -76,9 +77,9 @@ class ChatRoomController {
view.closeTab.call() view.closeTab.call()
} }
UUID uuid = UUID.randomUUID()
String room = model.console ? ChatServer.CONSOLE : model.room String room = model.console ? ChatServer.CONSOLE : model.room
UUID uuid = UUID.randomUUID()
byte [] sig = ChatConnection.sign(uuid, now, room, command.source, model.core.me, model.host, model.core.spk) byte [] sig = ChatConnection.sign(uuid, now, room, command.source, model.core.me, model.host, model.core.spk)
def event = new ChatMessageEvent(uuid : uuid, def event = new ChatMessageEvent(uuid : uuid,

View File

@@ -15,6 +15,7 @@ class ChatRoomModel {
String room String room
boolean console boolean console
boolean privateChat boolean privateChat
String roomTabName
def members = [] def members = []

View File

@@ -96,14 +96,15 @@ class ChatServerModel {
room = chatCommand.payload room = chatCommand.payload
} }
if (chatCommand.action == ChatAction.SAY && if (chatCommand.action == ChatAction.SAY &&
room == core.me.getHumanReadableName()) { room == core.me.toBase64()) {
if (!mvcGroup.childrenGroups.containsKey(e.sender.getHumanReadableName()+"-private-chat")) { if (!mvcGroup.childrenGroups.containsKey(e.sender.getHumanReadableName()+"-private-chat")) {
def params = [:] def params = [:]
params['core'] = core params['core'] = core
params['tabName'] = host.getHumanReadableName() + "-chat-rooms" params['tabName'] = host.getHumanReadableName() + "-chat-rooms"
params['room'] = e.sender.getHumanReadableName() params['room'] = e.sender.toBase64()
params['privateChat'] = true params['privateChat'] = true
params['host'] = host params['host'] = host
params['roomTabName'] = e.sender.getHumanReadableName()
mvcGroup.createMVCGroup("chat-room",e.sender.getHumanReadableName()+"-private-chat", params) mvcGroup.createMVCGroup("chat-room",e.sender.getHumanReadableName()+"-private-chat", params)
} }

View File

@@ -86,7 +86,7 @@ class ChatRoomView {
void mvcGroupInit(Map<String,String> args) { void mvcGroupInit(Map<String,String> args) {
parent = mvcGroup.parentGroup.view.builder.getVariable(model.tabName) parent = mvcGroup.parentGroup.view.builder.getVariable(model.tabName)
parent.addTab(model.room, pane) parent.addTab(model.roomTabName, pane)
int index = parent.indexOfComponent(pane) int index = parent.indexOfComponent(pane)
parent.setSelectedIndex(index) parent.setSelectedIndex(index)
@@ -94,7 +94,7 @@ class ChatRoomView {
def tabPanel = builder.panel { def tabPanel = builder.panel {
borderLayout() borderLayout()
panel (constraints : BorderLayout.CENTER) { panel (constraints : BorderLayout.CENTER) {
label(text : model.room) label(text : model.roomTabName)
} }
button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST, button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST,
actionPerformed : closeTab ) actionPerformed : closeTab )
@@ -122,6 +122,7 @@ class ChatRoomView {
params['room'] = p.getHumanReadableName() params['room'] = p.getHumanReadableName()
params['privateChat'] = true params['privateChat'] = true
params['host'] = model.host params['host'] = model.host
params['privateTarget'] = p
mvcGroup.parentGroup.createMVCGroup("chat-room", p.getHumanReadableName()+"-private-chat", params) mvcGroup.parentGroup.createMVCGroup("chat-room", p.getHumanReadableName()+"-private-chat", params)
} }