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