WIP bug fix

This commit is contained in:
GustavoHMDS committed 2026-09-28 18:59:20 -03:00
1 parent 57059c3ef0
commit ba2f41daf7
14 files changed
+72 -78

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../pitiupi/dist/pitiupi.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
@@ -8,7 +8,7 @@ public class SocketTestMenu extends JMenu {
public SocketTestMenu(SocketTestWindow socketTestWindow) {
this.socketTestWindow = socketTestWindow;
this.setText("Chat");
this.setText("MP-Chat");
JMenuItem menuItem = new JMenuItem();
menuItem.setText("Show Chat Window");
menuItem.addActionListener(this::showTestWindow);
@@ -96,7 +96,7 @@ public class SocketTestWindow extends JFrame {
try {
TestMessage msg = createMessage("TCP Unicast");
InetAddress ip = InetAddress.getByName(ipField.getText());
mainWindow.getSocketTCP().send(msg.toByteArray(), ip);
mainWindow.getSocketTCP().send(msg, ip);
} catch (Exception ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -106,7 +106,7 @@ public class SocketTestWindow extends JFrame {
try {
TestMessage msg = createMessage("UDP Unicast");
InetAddress ip = InetAddress.getByName(ipField.getText());
mainWindow.getSocketUDP().sendUnicast(msg.toByteArray(), ip);
mainWindow.getSocketUDP().sendUnicast(msg, ip);
} catch (Exception ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -114,7 +114,7 @@ public class SocketTestWindow extends JFrame {
public void sendMulticast() {
try {
TestMessage msg = createMessage("UDP Multicast");
mainWindow.getSocketUDP().sendMulticast(msg.toByteArray());
mainWindow.getSocketUDP().sendMulticast(msg);
} catch (Exception ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
+25 -4
View File
@@ -5,13 +5,14 @@ import GUI.SocketTestWindow;
import net.TestMessage;
import pitiupi.GUI.MainWindow;
import pitiupi.net.Message;
import pitiupi.plugin.Plugin;
import pitiupi.net.tcp.TcpConnection;
import pitiupi.plugin.PrivateConnectionPlugin;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
public class SocketTest implements Plugin{
public class SocketTest implements PrivateConnectionPlugin{
SocketTestWindow socketTestWindow;
@Override
@@ -29,6 +30,11 @@ public class SocketTest implements Plugin{
return "0";
}
@Override
public String getIdentifier() {
return "Socket.Test.123456";
}
@Override
public void createPlugin(MainWindow mainWindow) {
this.socketTestWindow = new SocketTestWindow(mainWindow);
@@ -41,8 +47,8 @@ public class SocketTest implements Plugin{
}
@Override
public void receiveMessage(byte[] bytes) {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
public void receiveMessage(byte[] message) {
ByteArrayInputStream bis = new ByteArrayInputStream(message);
ObjectInputStream ois;
try {
ois = new ObjectInputStream(bis);
@@ -53,4 +59,19 @@ public class SocketTest implements Plugin{
System.out.println(ex.toString());
}
}
@Override
public void receivePrivateConnection(TcpConnection tcpConnection) {
}
@Override
public void receiveBytes(TcpConnection connection, byte[] bytes) {
}
@Override
public void onSocketClosed(TcpConnection tcpConnection) {
}
}