WIP TCP bug fix
This commit is contained in:
1 parent
ba2f41daf7
commit
0ec3129a22
3 files changed
+7
-2
No files matched your search
@@ -62,6 +62,7 @@ public class ConnectionFactory {
|
||||
HandshakeMessage handshake = new HandshakeMessage(isPrivate, sender, receiver);
|
||||
|
||||
connection.send(handshake.toByteArray());
|
||||
System.out.println("Enviou handhsake");
|
||||
HandshakeMessage handshakeResponse = validateConnection(connection);
|
||||
|
||||
if (handshakeResponse == null) return null;
|
||||
@@ -148,12 +149,13 @@ public class ConnectionFactory {
|
||||
Object object = ois.readObject();
|
||||
|
||||
if (object instanceof Message message) {
|
||||
if (SysInfoMessage.parseSystemInfo(message) != null) {
|
||||
if (SysInfoMessage.parseSystemInfo(bytes) != null) {
|
||||
//TODO: Tratar erros
|
||||
return null;
|
||||
}
|
||||
|
||||
if (message instanceof HandshakeMessage handshake) {
|
||||
System.out.println("Recebeu handshake");
|
||||
return (validateHandshake(handshake, connection)) ? handshake : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ public class SocketTCP extends Thread {
|
||||
*/
|
||||
private void acceptIncomingConnection(Socket socket) {
|
||||
connectionExecutor.submit(() -> {
|
||||
System.out.println("Accepted TCP connection.");
|
||||
TcpConnection connection = ConnectionFactory.receiveConnection(socket);
|
||||
if (connection == null) return;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SocketUDP extends Thread {
|
||||
* @throws IOException caso ocorra um erro durante o envio.
|
||||
*/
|
||||
public void sendMulticast(Message msg) throws IOException {
|
||||
send(msg, this.address);
|
||||
send(msg, address);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,6 +144,8 @@ public class SocketUDP extends Thread {
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
System.out.println("Message! it is from: " + msgPacket.getSocketAddress());
|
||||
|
||||
HeartbeatMessage heartbeat = tryParseHeartbeat(msgPacket.getData());
|
||||
if (heartbeat != null) {
|
||||
main.getHeartbeatManager().receiveHeartbeat(heartbeat, msgPacket.getAddress());
|
||||
|
||||
Reference in new issue
Block a user