Create SocketConnection wrapper class

This commit is contained in:
Gaa56
2025-10-25 17:41:55 +01:00
parent 3fe467a2a3
commit 6c5eab0e72
2 changed files with 22 additions and 20 deletions

View File

@@ -1,44 +1,41 @@
package sd.protocol;
import java.io.Serializable;
import sd.model.MessageType;
import sd.model.MessageType; // Assuming MessageType is in sd.model or sd.protocol
/**
* Interface que define o contrato para todas as mensagens trocadas no simulador.
* Garante que qualquer mensagem possa ser identificada e roteada.
* * Esta interface estende Serializable para permitir que os objetos que a implementam
* sejam enviados através de Sockets (ObjectOutputStream).
* Interface defining the contract for all messages exchanged in the simulator.
* Ensures that any message can be identified and routed.
* * This interface extends Serializable to allow objects that implement it
* to be sent over Sockets (ObjectOutputStream).
*
*/
public interface MessageProtocol extends Serializable {
/**
* Retorna o tipo da mensagem, indicando o seu propósito.
* @return O MessageType (ex: VEHICLE_TRANSFER, STATS_UPDATE).
* Returns the type of the message, indicating its purpose.
* @return The MessageType (e.g., VEHICLE_TRANSFER, STATS_UPDATE).
*/
MessageType getType();
/**
* Retorna o objeto de dados (carga útil) que esta mensagem transporta.
* O tipo de objeto dependerá do MessageType.
* * - Se getType() == VEHICLE_TRANSFER, o payload será um objeto {@link sd.model.Vehicle}.
* - Se getType() == STATS_UPDATE, o payload será um objeto de estatísticas.
* * @return O objeto de dados (payload), que também deve ser Serializable.
* Returns the data object (payload) that this message carries.
* The type of object will depend on the MessageType.
* * - If getType() == VEHICLE_TRANSFER, the payload will be a {@link sd.model.Vehicle} object.
* - If getType() == STATS_UPDATE, the payload will be a statistics object.
* * @return The data object (payload), which must also be Serializable.
*/
Object getPayload();
/**
* Retorna o ID do nó (Processo) que enviou esta mensagem.
* @return String (ex: "Cr1", "Cr5", "S").
* Returns the ID of the node (Process) that sent this message.
* @return String (e.g., "Cr1", "Cr5", "S").
*/
String getSourceNode();
/**
* Retorna o ID do nó (Processo) de destino desta mensagem.
* @return String (ex: "Cr2", "DashboardServer").
* Returns the ID of the destination node (Process) for this message.
* @return String (e.g., "Cr2", "DashboardServer").
*/
String getDestinationNode();
}

View File

@@ -0,0 +1,5 @@
package sd.protocol;
public class SocketConnection {
}