1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package de.tudarmstadt.informatik.hostage.protocol;
- import java.util.List;
- /**
- * Interface for protocols that are used by hostage
- * @param <T> Denotes if the protocol is using Strings or ByteArrays
- */
- public interface Protocol<T> {
- /**
- * 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<T> 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<T> getType();
-
- /**
- * Returns the name of the protocol
- * @return name of the protocol
- */
- @Override
- String toString();
- }
|