package de.tudarmstadt.informatik.hostage.protocol; import java.util.List; /** * Interface for protocols that are used by the application. * @param Denotes if the protocol is using Strings or ByteArrays. */ public interface Protocol { /** * Represents who starts the communication once the connection is established. */ public static enum TALK_FIRST { SERVER, CLIENT }; /** * Returns the port on which the protocol is running. * @return the port used by the protocol (range: 0-65535) */ int getPort(); /** * Returns who starts the communication (server or client) * @return TALK_FIRST.server if the server starts or TALK_FIRST.client if the client starts. */ TALK_FIRST whoTalksFirst(); /** * Determines the next message that is sent by the server. * @param message last message that was sent by the client. * @return next message that will be sent. */ List processMessage(T message); /** * Returns whether the communication is ended and the connection should be closed or not. * @return true if the connection should be closed, else false. */ boolean isClosed(); /** * Returns if the protocol uses SSL/TLS connection or not. * @return true if SSL/TLS is used, else false. */ boolean isSecure(); /** * Returns what type the protocol is using, Strings or ByteArrays. * @return the class that the protocol is using. */ Class getType(); /** * Returns the name of the protocol. * @return name of the protocol */ @Override String toString(); }