mirror of
https://github.com/davidalves04/Trabalho-Pratico-SD.git
synced 2025-12-08 20:43:32 +00:00
Merge branch 'dev' into cleanup
This commit is contained in:
@@ -40,6 +40,7 @@ import sd.protocol.SocketConnection;
|
||||
*/
|
||||
public class ExitNodeProcess {
|
||||
|
||||
// --- Configuration and Networking ---
|
||||
private final SimulationConfig config;
|
||||
private ServerSocket serverSocket;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package sd.protocol;
|
||||
|
||||
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.
|
||||
|
||||
@@ -30,9 +30,30 @@ import sd.serialization.SerializerFactory;
|
||||
*/
|
||||
public class SocketConnection implements Closeable {
|
||||
|
||||
// --- Network Resources ---
|
||||
|
||||
/**
|
||||
* The underlying TCP socket used for network communication.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* The raw input stream for reading bytes from the network.
|
||||
* Wrapped by {@link DataInputStream} during message reception.
|
||||
*/
|
||||
private final InputStream inputStream;
|
||||
|
||||
// --- Serialization ---
|
||||
|
||||
/**
|
||||
* The serializer strategy used to convert objects to/from byte arrays (e.g., JSON).
|
||||
*/
|
||||
private final MessageSerializer serializer;
|
||||
|
||||
/** Número máximo de tentativas de ligação antes de desistir (Fail-fast). */
|
||||
@@ -169,7 +190,7 @@ public class SocketConnection implements Closeable {
|
||||
}
|
||||
|
||||
try {
|
||||
// Lê um prefixo de 4 bytes - indicador de tamanho
|
||||
|
||||
DataInputStream dataIn = new DataInputStream(inputStream);
|
||||
int length = dataIn.readInt();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user