BugFix e atualização da interface no mpChat
This commit is contained in:
1 parent
7a699cd280
commit
581a924afc
8 files changed
+220
-177
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
plugin.MultiProtocolChat
|
||||||
@@ -1,201 +1,121 @@
|
|||||||
package GUI;
|
package GUI;
|
||||||
|
|
||||||
import net.MpChatMessage;
|
import net.MpChatMessage;
|
||||||
import pitiupi.control.ConnectionManager;
|
|
||||||
import pitiupi.net.tcp.TcpConnection;
|
import pitiupi.net.tcp.TcpConnection;
|
||||||
import pitiupi.plugin.Pitiupi;
|
import pitiupi.plugin.Pitiupi;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PrivateChatWindow extends JFrame {
|
public class PrivateChatWindow extends JFrame {
|
||||||
|
|
||||||
private final Pitiupi pitiupi;
|
private final Pitiupi pitiupi;
|
||||||
|
private final TcpConnection connection;
|
||||||
|
|
||||||
private final Map<TcpConnection, PrivateChatPanel> chats;
|
private final JTextArea receivedMessagesArea;
|
||||||
|
private final JTextField messageField;
|
||||||
|
|
||||||
private final JPanel chatPanel;
|
public PrivateChatWindow(
|
||||||
private final CardLayout cardLayout;
|
Pitiupi pitiupi,
|
||||||
|
TcpConnection connection
|
||||||
private final DefaultListModel<TcpConnection> connectionListModel;
|
) {
|
||||||
private final JList<TcpConnection> connectionList;
|
|
||||||
|
|
||||||
public PrivateChatWindow(Pitiupi pitiupi) {
|
|
||||||
this.pitiupi = pitiupi;
|
this.pitiupi = pitiupi;
|
||||||
this.chats = new HashMap<>();
|
this.connection = connection;
|
||||||
|
|
||||||
setTitle("Chats privados");
|
setTitle("Chat privado");
|
||||||
setSize(700, 500);
|
setSize(700, 500);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
mainPanel.setBorder(
|
||||||
|
BorderFactory.createEmptyBorder(10, 10, 10, 10)
|
||||||
connectionListModel = new DefaultListModel<>();
|
|
||||||
connectionList = new JList<>(connectionListModel);
|
|
||||||
|
|
||||||
connectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
||||||
connectionList.setPreferredSize(new Dimension(180, 0));
|
|
||||||
|
|
||||||
connectionList.addListSelectionListener(e -> {
|
|
||||||
if (!e.getValueIsAdjusting()) {
|
|
||||||
TcpConnection connection = connectionList.getSelectedValue();
|
|
||||||
|
|
||||||
if (connection != null) {
|
|
||||||
showChat(connection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JScrollPane connectionScrollPane = new JScrollPane(connectionList);
|
|
||||||
connectionScrollPane.setBorder(
|
|
||||||
BorderFactory.createTitledBorder("Usuários")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
mainPanel.add(connectionScrollPane, BorderLayout.WEST);
|
receivedMessagesArea = new JTextArea();
|
||||||
|
receivedMessagesArea.setEditable(false);
|
||||||
|
receivedMessagesArea.setLineWrap(true);
|
||||||
|
receivedMessagesArea.setWrapStyleWord(true);
|
||||||
|
|
||||||
cardLayout = new CardLayout();
|
JScrollPane messagesScrollPane =
|
||||||
chatPanel = new JPanel(cardLayout);
|
new JScrollPane(receivedMessagesArea);
|
||||||
|
|
||||||
mainPanel.add(chatPanel, BorderLayout.CENTER);
|
messagesScrollPane.setBorder(
|
||||||
|
BorderFactory.createTitledBorder("Mensagens")
|
||||||
|
);
|
||||||
|
|
||||||
|
mainPanel.add(
|
||||||
|
messagesScrollPane,
|
||||||
|
BorderLayout.CENTER
|
||||||
|
);
|
||||||
|
|
||||||
|
JPanel bottomPanel = new JPanel(
|
||||||
|
new BorderLayout(10, 10)
|
||||||
|
);
|
||||||
|
|
||||||
|
messageField = new JTextField();
|
||||||
|
|
||||||
|
JButton tcpButton = new JButton("TCP");
|
||||||
|
tcpButton.addActionListener(e -> sendTCP());
|
||||||
|
|
||||||
|
bottomPanel.add(
|
||||||
|
messageField,
|
||||||
|
BorderLayout.CENTER
|
||||||
|
);
|
||||||
|
|
||||||
|
bottomPanel.add(
|
||||||
|
tcpButton,
|
||||||
|
BorderLayout.EAST
|
||||||
|
);
|
||||||
|
|
||||||
|
mainPanel.add(
|
||||||
|
bottomPanel,
|
||||||
|
BorderLayout.SOUTH
|
||||||
|
);
|
||||||
|
|
||||||
setContentPane(mainPanel);
|
setContentPane(mainPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConnection(TcpConnection connection) {
|
private void sendTCP() {
|
||||||
if (chats.containsKey(connection)) {
|
try {
|
||||||
return;
|
String nome = pitiupi.getUserName();
|
||||||
}
|
|
||||||
|
|
||||||
PrivateChatPanel panel = new PrivateChatPanel(connection);
|
MpChatMessage message = new MpChatMessage(
|
||||||
|
nome,
|
||||||
chats.put(connection, panel);
|
InetAddress.getLocalHost().getHostAddress(),
|
||||||
connectionListModel.addElement(connection);
|
"TCP Private",
|
||||||
|
messageField.getText()
|
||||||
String cardName = getCardName(connection);
|
|
||||||
chatPanel.add(panel, cardName);
|
|
||||||
|
|
||||||
if (connectionList.getSelectedValue() == null) {
|
|
||||||
connectionList.setSelectedValue(connection, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeConnection(TcpConnection connection) {
|
|
||||||
PrivateChatPanel panel = chats.remove(connection);
|
|
||||||
|
|
||||||
if (panel == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
chatPanel.remove(panel);
|
|
||||||
connectionListModel.removeElement(connection);
|
|
||||||
|
|
||||||
if (!connectionListModel.isEmpty()) {
|
|
||||||
connectionList.setSelectedIndex(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void receiveMessage(TcpConnection connection, MpChatMessage message) {
|
|
||||||
PrivateChatPanel panel = chats.get(connection);
|
|
||||||
|
|
||||||
if (panel == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
panel.receiveMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showChat(TcpConnection connection) {
|
|
||||||
cardLayout.show(chatPanel, getCardName(connection));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCardName(TcpConnection connection) {
|
|
||||||
return Integer.toHexString(System.identityHashCode(connection));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PrivateChatPanel extends JPanel {
|
|
||||||
|
|
||||||
private final TcpConnection connection;
|
|
||||||
|
|
||||||
private final JTextArea receivedMessagesArea;
|
|
||||||
private final JTextField messageField;
|
|
||||||
|
|
||||||
public PrivateChatPanel(TcpConnection connection) {
|
|
||||||
this.connection = connection;
|
|
||||||
|
|
||||||
setLayout(new BorderLayout(10, 10));
|
|
||||||
|
|
||||||
receivedMessagesArea = new JTextArea();
|
|
||||||
receivedMessagesArea.setEditable(false);
|
|
||||||
receivedMessagesArea.setLineWrap(true);
|
|
||||||
receivedMessagesArea.setWrapStyleWord(true);
|
|
||||||
|
|
||||||
JScrollPane messagesScrollPane =
|
|
||||||
new JScrollPane(receivedMessagesArea);
|
|
||||||
|
|
||||||
messagesScrollPane.setBorder(
|
|
||||||
BorderFactory.createTitledBorder("Mensagens")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
add(messagesScrollPane, BorderLayout.CENTER);
|
connection.send(message.toByteArray());
|
||||||
|
|
||||||
JPanel bottomPanel = new JPanel(new BorderLayout(10, 10));
|
messageField.setText("");
|
||||||
|
|
||||||
messageField = new JTextField();
|
} catch (Exception ex) {
|
||||||
|
Logger.getLogger(
|
||||||
JButton tcpButton = new JButton("TCP");
|
PrivateChatWindow.class.getName()
|
||||||
tcpButton.addActionListener(e -> sendTCP());
|
).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
bottomPanel.add(messageField, BorderLayout.CENTER);
|
|
||||||
bottomPanel.add(tcpButton, BorderLayout.EAST);
|
|
||||||
|
|
||||||
add(bottomPanel, BorderLayout.SOUTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendTCP() {
|
|
||||||
try {
|
|
||||||
String nome = pitiupi.getUserName();
|
|
||||||
|
|
||||||
MpChatMessage message = new MpChatMessage(
|
|
||||||
nome,
|
|
||||||
InetAddress.getLocalHost().toString(),
|
|
||||||
"TCP Private",
|
|
||||||
messageField.getText()
|
|
||||||
);
|
|
||||||
|
|
||||||
connection.send(message.toByteArray());
|
|
||||||
|
|
||||||
messageField.setText("");
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(
|
|
||||||
PrivateChatWindow.class.getName()
|
|
||||||
).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void receiveMessage(MpChatMessage message) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
String texto = String.format(
|
|
||||||
"[%s] %s (%s): %s%n",
|
|
||||||
message.getTipoMensagem(),
|
|
||||||
message.getNome(),
|
|
||||||
message.getIp(),
|
|
||||||
message.getMessage()
|
|
||||||
);
|
|
||||||
|
|
||||||
receivedMessagesArea.append(texto);
|
|
||||||
|
|
||||||
receivedMessagesArea.setCaretPosition(
|
|
||||||
receivedMessagesArea.getDocument().getLength()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void receiveMessage(MpChatMessage message) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
String texto = String.format(
|
||||||
|
"[%s] %s (%s): %s%n",
|
||||||
|
message.getTipoMensagem(),
|
||||||
|
message.getNome(),
|
||||||
|
message.getIp(),
|
||||||
|
message.getMessage()
|
||||||
|
);
|
||||||
|
|
||||||
|
receivedMessagesArea.append(texto);
|
||||||
|
|
||||||
|
receivedMessagesArea.setCaretPosition(
|
||||||
|
receivedMessagesArea.getDocument().getLength()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,26 @@
|
|||||||
package GUI;
|
package GUI;
|
||||||
|
|
||||||
|
import control.PrivateChatController;
|
||||||
import pitiupi.models.Menus.UnicastMenus.UnicastActionMenu;
|
import pitiupi.models.Menus.UnicastMenus.UnicastActionMenu;
|
||||||
import pitiupi.models.User;
|
import pitiupi.models.User;
|
||||||
import plugin.MultiProtocolChat;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class UnicastMpChatMenu extends UnicastActionMenu {
|
public class UnicastMpChatMenu extends UnicastActionMenu {
|
||||||
private final MultiProtocolChat multiProtocolChat;
|
|
||||||
|
|
||||||
public UnicastMpChatMenu(MultiProtocolChat multiProtocolChat) {
|
private final PrivateChatController controller;
|
||||||
this.multiProtocolChat = multiProtocolChat;
|
|
||||||
|
public UnicastMpChatMenu(
|
||||||
|
PrivateChatController controller
|
||||||
|
) {
|
||||||
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(User user) {
|
public void onClick(User user) {
|
||||||
multiProtocolChat.openConnection(user.getAddress().toString());
|
controller.openChat(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return "start Private Chat";
|
return "Start Private Chat";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package control;
|
||||||
|
|
||||||
|
import GUI.PrivateChatWindow;
|
||||||
|
import net.MpChatMessage;
|
||||||
|
import pitiupi.models.User;
|
||||||
|
import pitiupi.net.tcp.TcpConnection;
|
||||||
|
import pitiupi.plugin.Pitiupi;
|
||||||
|
import plugin.MultiProtocolChat;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PrivateChatController {
|
||||||
|
|
||||||
|
private final Pitiupi pitiupi;
|
||||||
|
private final MultiProtocolChat multiProtocolChat;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Relaciona o endereço do usuário à janela de chat.
|
||||||
|
*/
|
||||||
|
private final Map<String, PrivateChatWindow> windows;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Endereços para os quais uma conexão já foi solicitada,
|
||||||
|
* mas ainda não chegou.
|
||||||
|
*/
|
||||||
|
private final Set<String> pendingConnections;
|
||||||
|
|
||||||
|
public PrivateChatController(
|
||||||
|
Pitiupi pitiupi,
|
||||||
|
MultiProtocolChat multiProtocolChat
|
||||||
|
) {
|
||||||
|
this.pitiupi = pitiupi;
|
||||||
|
this.multiProtocolChat = multiProtocolChat;
|
||||||
|
|
||||||
|
this.windows = new HashMap<>();
|
||||||
|
this.pendingConnections = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openChat(User user) {
|
||||||
|
String address = user.getAddress().getHostAddress();
|
||||||
|
|
||||||
|
PrivateChatWindow window = windows.get(address);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Já existe uma janela para esse usuário.
|
||||||
|
*/
|
||||||
|
if (window != null) {
|
||||||
|
window.setVisible(true);
|
||||||
|
window.toFront();
|
||||||
|
window.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Já estamos esperando uma conexão para esse usuário.
|
||||||
|
*/
|
||||||
|
if (pendingConnections.contains(address)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ainda não existe conexão.
|
||||||
|
*/
|
||||||
|
pendingConnections.add(address);
|
||||||
|
|
||||||
|
multiProtocolChat.openConnection(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void receiveMessage(TcpConnection connection, MpChatMessage message) {
|
||||||
|
String address = connection.getAddress().toString();
|
||||||
|
|
||||||
|
PrivateChatWindow window = windows.get(address);
|
||||||
|
|
||||||
|
if (window == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.receiveMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deve ser chamado quando uma nova conexão privada chegar.
|
||||||
|
*/
|
||||||
|
public void connectionReceived(TcpConnection connection) {
|
||||||
|
String address = connection.getAddress().toString();
|
||||||
|
|
||||||
|
pendingConnections.remove(address);
|
||||||
|
|
||||||
|
PrivateChatWindow window = new PrivateChatWindow(
|
||||||
|
pitiupi,
|
||||||
|
connection
|
||||||
|
);
|
||||||
|
|
||||||
|
windows.put(address, window);
|
||||||
|
|
||||||
|
window.setVisible(true);
|
||||||
|
window.toFront();
|
||||||
|
window.requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fecha a janela e remove o relacionamento.
|
||||||
|
*/
|
||||||
|
public void closeChat(TcpConnection connection) {
|
||||||
|
String address = connection.getAddress().toString();
|
||||||
|
|
||||||
|
PrivateChatWindow window = windows.remove(address);
|
||||||
|
|
||||||
|
if (window != null) {
|
||||||
|
window.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import GUI.MulticastMpChatMenu;
|
|||||||
import GUI.PrivateChatWindow;
|
import GUI.PrivateChatWindow;
|
||||||
import GUI.PublicChatWindow;
|
import GUI.PublicChatWindow;
|
||||||
import GUI.UnicastMpChatMenu;
|
import GUI.UnicastMpChatMenu;
|
||||||
|
import control.PrivateChatController;
|
||||||
import net.MpChatMessage;
|
import net.MpChatMessage;
|
||||||
import pitiupi.models.Menus.MenuCategory;
|
import pitiupi.models.Menus.MenuCategory;
|
||||||
import pitiupi.models.Messages.Message;
|
import pitiupi.models.Messages.Message;
|
||||||
@@ -21,8 +22,8 @@ import java.util.List;
|
|||||||
public class MultiProtocolChat extends Plugin {
|
public class MultiProtocolChat extends Plugin {
|
||||||
Pitiupi pitiupi;
|
Pitiupi pitiupi;
|
||||||
|
|
||||||
|
PrivateChatController privateChatController;
|
||||||
PublicChatWindow publicChatWindow;
|
PublicChatWindow publicChatWindow;
|
||||||
PrivateChatWindow privateChatWindow;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -48,11 +49,12 @@ public class MultiProtocolChat extends Plugin {
|
|||||||
public void createPlugin(Pitiupi pitiupi) {
|
public void createPlugin(Pitiupi pitiupi) {
|
||||||
this.pitiupi = pitiupi;
|
this.pitiupi = pitiupi;
|
||||||
|
|
||||||
|
privateChatController = new PrivateChatController(pitiupi, this);
|
||||||
|
|
||||||
publicChatWindow = new PublicChatWindow(pitiupi);
|
publicChatWindow = new PublicChatWindow(pitiupi);
|
||||||
privateChatWindow = new PrivateChatWindow(pitiupi);
|
|
||||||
|
|
||||||
MulticastMpChatMenu multicastMpChatMenu = new MulticastMpChatMenu(publicChatWindow);
|
MulticastMpChatMenu multicastMpChatMenu = new MulticastMpChatMenu(publicChatWindow);
|
||||||
UnicastMpChatMenu unicastMpChatMenu = new UnicastMpChatMenu(this);
|
UnicastMpChatMenu unicastMpChatMenu = new UnicastMpChatMenu(privateChatController);
|
||||||
|
|
||||||
pitiupi.createMenu(MenuCategory.Social, multicastMpChatMenu);
|
pitiupi.createMenu(MenuCategory.Social, multicastMpChatMenu);
|
||||||
pitiupi.createMenu(MenuCategory.Social, unicastMpChatMenu);
|
pitiupi.createMenu(MenuCategory.Social, unicastMpChatMenu);
|
||||||
@@ -74,7 +76,7 @@ public class MultiProtocolChat extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public boolean receivePrivateConnection(TcpConnection connection) {
|
public boolean receivePrivateConnection(TcpConnection connection) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
privateChatWindow.addConnection(connection);
|
privateChatController.connectionReceived(connection);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -82,13 +84,13 @@ public class MultiProtocolChat extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public boolean receiveBytes(TcpConnection connection, byte[] bytes) {
|
public boolean receiveBytes(TcpConnection connection, byte[] bytes) {
|
||||||
MpChatMessage mpChatMessage = parseMessage(bytes);
|
MpChatMessage mpChatMessage = parseMessage(bytes);
|
||||||
privateChatWindow.receiveMessage(connection, mpChatMessage);
|
privateChatController.receiveMessage(connection, mpChatMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSocketClosed(TcpConnection connection) {
|
public boolean onSocketClosed(TcpConnection connection) {
|
||||||
privateChatWindow.removeConnection(connection);
|
privateChatController.closeChat(connection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ public class MenuBar extends JMenuBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPluginMenu(MenuCategory category, JMenuItem menu){
|
public void addPluginMenu(MenuCategory category, JMenuItem menu){
|
||||||
System.out.println("addPluginMenu");
|
|
||||||
categories.get(category).add(menu);
|
categories.get(category).add(menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,8 @@ public class SocketTCP extends Thread {
|
|||||||
try {
|
try {
|
||||||
serverSocket = new ServerSocket(connectionManager.getPort());
|
serverSocket = new ServerSocket(connectionManager.getPort());
|
||||||
address = InetAddress.getByName(InetAddress.getLocalHost().getHostAddress());
|
address = InetAddress.getByName(InetAddress.getLocalHost().getHostAddress());
|
||||||
|
if (address != null) System.out.println("SocketTCP: "+ address);
|
||||||
|
else System.out.println("Adress: Null");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("There is no socket connection. Sorry.");
|
System.out.println("There is no socket connection. Sorry.");
|
||||||
System.out.println(ex.toString());
|
System.out.println(ex.toString());
|
||||||
@@ -336,7 +338,7 @@ public class SocketTCP extends Thread {
|
|||||||
* ao plugin destinatário.
|
* ao plugin destinatário.
|
||||||
*
|
*
|
||||||
* <p>Dados que não representam mensagens de controle são entregues
|
* <p>Dados que não representam mensagens de controle são entregues
|
||||||
* diretamente ao {@link PrivateConnectionPlugin}. Mensagens de controle
|
* diretamente ao {@link pitiupi.models.Plugin}. Mensagens de controle
|
||||||
* relacionadas ao encerramento ou a erros internos provocam a notificação
|
* relacionadas ao encerramento ou a erros internos provocam a notificação
|
||||||
* do plugin e o fechamento da conexão.</p>
|
* do plugin e o fechamento da conexão.</p>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class TcpConnection {
|
|||||||
this.input = new DataInputStream(socket.getInputStream());
|
this.input = new DataInputStream(socket.getInputStream());
|
||||||
this.output = new DataOutputStream(socket.getOutputStream());
|
this.output = new DataOutputStream(socket.getOutputStream());
|
||||||
this.address = socket.getInetAddress();
|
this.address = socket.getInetAddress();
|
||||||
|
if (address != null) System.out.println("TcpConnection: " + address);
|
||||||
|
else System.out.println("Adress: Null");
|
||||||
this.lastActivity = System.currentTimeMillis();
|
this.lastActivity = System.currentTimeMillis();
|
||||||
this.timeout = 300_000; // 5 minutos
|
this.timeout = 300_000; // 5 minutos
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user