Protocol.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package de.tudarmstadt.informatik.hostage.protocol;
  2. import java.util.List;
  3. import javax.net.ssl.SSLContext;
  4. /**
  5. * Interface for protocols that are used by hostage
  6. * @param <T> Denotes if the protocol is using Strings or ByteArrays
  7. */
  8. public interface Protocol<T> {
  9. /**
  10. * Represents who starts the communication once the connection is established
  11. */
  12. public static enum TALK_FIRST {
  13. SERVER, CLIENT
  14. };
  15. /**
  16. * Returns the port on which the protocol is running
  17. * @return the port used by the protocol (range: 0-65535)
  18. */
  19. int getPort();
  20. /**
  21. * Returns who starts the communication (server or client)
  22. * @return TALK_FIRST.server if the server starts or TALK_FIRST.client if the client starts
  23. */
  24. TALK_FIRST whoTalksFirst();
  25. /**
  26. * Determines the next message that is sent by the server
  27. * @param message last message that was sent by the client
  28. * @return next message that will be sent
  29. */
  30. List<T> processMessage(T message);
  31. /**
  32. * Returns whether the communication is ended and the connection should be closed or not
  33. * @return true if the connection should be closed, else false
  34. */
  35. boolean isClosed();
  36. /**
  37. * Returns if the protocol uses SSL/TLS connection or not
  38. * @return true if SSL/TLS is used, else false
  39. */
  40. boolean isSecure();
  41. /**
  42. * Returns what type the protocol is using, Strings or ByteArrays
  43. * @return the class that the protocol is using
  44. */
  45. Class<T> getType();
  46. /**
  47. * Returns the name of the protocol
  48. * @return name of the protocol
  49. */
  50. @Override
  51. String toString();
  52. }