mirror of
https://github.com/davidalves04/Trabalho-Pratico-SD.git
synced 2025-12-08 12:33:31 +00:00
Create SocketConnection wrapper class
This commit is contained in:
@@ -1,44 +1,41 @@
|
|||||||
package sd.protocol;
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface que define o contrato para todas as mensagens trocadas no simulador.
|
* Interface defining the contract for all messages exchanged in the simulator.
|
||||||
* Garante que qualquer mensagem possa ser identificada e roteada.
|
* Ensures that any message can be identified and routed.
|
||||||
* * Esta interface estende Serializable para permitir que os objetos que a implementam
|
* * This interface extends Serializable to allow objects that implement it
|
||||||
* sejam enviados através de Sockets (ObjectOutputStream).
|
* to be sent over Sockets (ObjectOutputStream).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface MessageProtocol extends Serializable {
|
public interface MessageProtocol extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retorna o tipo da mensagem, indicando o seu propósito.
|
* Returns the type of the message, indicating its purpose.
|
||||||
* @return O MessageType (ex: VEHICLE_TRANSFER, STATS_UPDATE).
|
* @return The MessageType (e.g., VEHICLE_TRANSFER, STATS_UPDATE).
|
||||||
*/
|
*/
|
||||||
MessageType getType();
|
MessageType getType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retorna o objeto de dados (carga útil) que esta mensagem transporta.
|
* Returns the data object (payload) that this message carries.
|
||||||
* O tipo de objeto dependerá do MessageType.
|
* The type of object will depend on the MessageType.
|
||||||
* * - Se getType() == VEHICLE_TRANSFER, o payload será um objeto {@link sd.model.Vehicle}.
|
* * - If getType() == VEHICLE_TRANSFER, the payload will be a {@link sd.model.Vehicle} object.
|
||||||
* - Se getType() == STATS_UPDATE, o payload será um objeto de estatísticas.
|
* - If getType() == STATS_UPDATE, the payload will be a statistics object.
|
||||||
* * @return O objeto de dados (payload), que também deve ser Serializable.
|
* * @return The data object (payload), which must also be Serializable.
|
||||||
*/
|
*/
|
||||||
Object getPayload();
|
Object getPayload();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retorna o ID do nó (Processo) que enviou esta mensagem.
|
* Returns the ID of the node (Process) that sent this message.
|
||||||
* @return String (ex: "Cr1", "Cr5", "S").
|
* @return String (e.g., "Cr1", "Cr5", "S").
|
||||||
*/
|
*/
|
||||||
String getSourceNode();
|
String getSourceNode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retorna o ID do nó (Processo) de destino desta mensagem.
|
* Returns the ID of the destination node (Process) for this message.
|
||||||
* @return String (ex: "Cr2", "DashboardServer").
|
* @return String (e.g., "Cr2", "DashboardServer").
|
||||||
*/
|
*/
|
||||||
String getDestinationNode();
|
String getDestinationNode();
|
||||||
}
|
}
|
||||||
5
main/src/main/java/sd/protocol/SocketConnection.java
Normal file
5
main/src/main/java/sd/protocol/SocketConnection.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package sd.protocol;
|
||||||
|
|
||||||
|
public class SocketConnection {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user