Protocol.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package de.tudarmstadt.informatik.hostage.protocol;
  2. import java.util.List;
  3. import de.tudarmstadt.informatik.hostage.wrapper.Packet;
  4. /**
  5. * Protocol interface.
  6. *
  7. * @author Mihai Plasoianu
  8. * @author Wulf Pfeiffer
  9. */
  10. public interface Protocol {
  11. public static enum TALK_FIRST {
  12. SERVER, CLIENT
  13. };
  14. /**
  15. * Returns the port on which the protocol is running.
  16. *
  17. * @return The port used by the protocol (1-65535)
  18. */
  19. int getPort();
  20. /**
  21. * Returns whether the communication is ended and the connection should be
  22. * closed or not.
  23. *
  24. * @return true if the connection should be closed, false otherwise.
  25. */
  26. boolean isClosed();
  27. /**
  28. * Returns whether the protocol uses a secure connection or not.
  29. *
  30. * @return true if SSL/TLS is used, false otherwise.
  31. */
  32. boolean isSecure();
  33. /**
  34. * Determines the next response.
  35. *
  36. * @param message
  37. * Last message received from the client.
  38. * @return Message to be sent to the client.
  39. */
  40. List<Packet> processMessage(Packet message);
  41. /**
  42. * Returns the name of the protocol.
  43. *
  44. * @return String representation of the protocol.
  45. */
  46. @Override
  47. String toString();
  48. /**
  49. * Specifies who starts the communication once the connection is
  50. * established.
  51. *
  52. * @return A value in TALK_FIRST.
  53. */
  54. TALK_FIRST whoTalksFirst();
  55. }