Protocol.java 1.6 KB

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