WIP bug fix 3
This commit is contained in:
1 parent
fa4ee046b1
commit
23559dcc06
5 files changed
+8
-5
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,7 +20,6 @@ public class ChatController {
|
|||||||
private final HashMap<TcpConnection, JMenuItem> chatMenus;
|
private final HashMap<TcpConnection, JMenuItem> chatMenus;
|
||||||
private final HashMap<TcpConnection, ChatWindow> chatWindows;
|
private final HashMap<TcpConnection, ChatWindow> chatWindows;
|
||||||
|
|
||||||
|
|
||||||
public ChatController(MainWindow mainWindow, ChatMenu chatMenu) {
|
public ChatController(MainWindow mainWindow, ChatMenu chatMenu) {
|
||||||
this.mainWindow = mainWindow;
|
this.mainWindow = mainWindow;
|
||||||
publicChatWindow = new PublicChatWindow(mainWindow);
|
publicChatWindow = new PublicChatWindow(mainWindow);
|
||||||
@@ -28,7 +27,9 @@ public class ChatController {
|
|||||||
chatMenus = new HashMap<>();
|
chatMenus = new HashMap<>();
|
||||||
chatWindows = new HashMap<>();
|
chatWindows = new HashMap<>();
|
||||||
|
|
||||||
chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow);
|
this.chatMenu = chatMenu;
|
||||||
|
|
||||||
|
this.chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChatWindow(TcpConnection tcpConnection) {
|
public void addChatWindow(TcpConnection tcpConnection) {
|
||||||
@@ -36,10 +37,8 @@ public class ChatController {
|
|||||||
|
|
||||||
PrivateChatWindow newChat = new PrivateChatWindow(mainWindow, tcpConnection);
|
PrivateChatWindow newChat = new PrivateChatWindow(mainWindow, tcpConnection);
|
||||||
chatWindows.put(tcpConnection, newChat);
|
chatWindows.put(tcpConnection, newChat);
|
||||||
|
|
||||||
JMenuItem newMenuItem = new JMenuItem();
|
JMenuItem newMenuItem = new JMenuItem();
|
||||||
chatMenus.put(tcpConnection, newMenuItem);
|
chatMenus.put(tcpConnection, newMenuItem);
|
||||||
|
|
||||||
newMenuItem.setText(tcpConnection.getAddress().toString());
|
newMenuItem.setText(tcpConnection.getAddress().toString());
|
||||||
chatMenu.newMenuItem(newMenuItem, newChat);
|
chatMenu.newMenuItem(newMenuItem, newChat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import pitiupi.net.Message;
|
|||||||
import pitiupi.net.tcp.TcpConnection;
|
import pitiupi.net.tcp.TcpConnection;
|
||||||
import pitiupi.plugin.PrivateConnectionPlugin;
|
import pitiupi.plugin.PrivateConnectionPlugin;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
@@ -57,9 +58,12 @@ public class TestChat implements PrivateConnectionPlugin{
|
|||||||
chatController.receivePublic(testChatMessage);
|
chatController.receivePublic(testChatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivePrivateConnection(TcpConnection tcpConnection) {
|
public void receivePrivateConnection(TcpConnection tcpConnection) {
|
||||||
chatController.addChatWindow(tcpConnection);
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
chatController.addChatWindow(tcpConnection);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user