Merge branch 'dev' into cleanup

This commit is contained in:
2025-12-07 23:21:44 +00:00
committed by GitHub
3 changed files with 24 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ import sd.protocol.SocketConnection;
*/ */
public class ExitNodeProcess { public class ExitNodeProcess {
// --- Configuration and Networking ---
private final SimulationConfig config; private final SimulationConfig config;
private ServerSocket serverSocket; private ServerSocket serverSocket;

View File

@@ -2,7 +2,7 @@ package sd.protocol;
import java.io.Serializable; import java.io.Serializable;
import sd.model.MessageType; // Assuming MessageType is in sd.model or sd.protocol import sd.model.MessageType;
/** /**
* Contrato para todas as mensagens trocadas no simulador. * Contrato para todas as mensagens trocadas no simulador.

View File

@@ -30,9 +30,30 @@ import sd.serialization.SerializerFactory;
*/ */
public class SocketConnection implements Closeable { public class SocketConnection implements Closeable {
// --- Network Resources ---
/**
* The underlying TCP socket used for network communication.
*/
private final Socket socket; private final Socket socket;
/**
* The raw output stream for writing bytes to the network.
* Wrapped by {@link DataOutputStream} during message sending.
*/
private final OutputStream outputStream; private final OutputStream outputStream;
/**
* The raw input stream for reading bytes from the network.
* Wrapped by {@link DataInputStream} during message reception.
*/
private final InputStream inputStream; private final InputStream inputStream;
// --- Serialization ---
/**
* The serializer strategy used to convert objects to/from byte arrays (e.g., JSON).
*/
private final MessageSerializer serializer; private final MessageSerializer serializer;
/** Número máximo de tentativas de ligação antes de desistir (Fail-fast). */ /** Número máximo de tentativas de ligação antes de desistir (Fail-fast). */
@@ -169,7 +190,7 @@ public class SocketConnection implements Closeable {
} }
try { try {
// Lê um prefixo de 4 bytes - indicador de tamanho
DataInputStream dataIn = new DataInputStream(inputStream); DataInputStream dataIn = new DataInputStream(inputStream);
int length = dataIn.readInt(); int length = dataIn.readInt();