SendMessage.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*******************************************************************************
  2. * The MIT License (MIT)
  3. *
  4. * Copyright 2017 Dr.-Ing. Marc Mültin (V2G Clarity)
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. *******************************************************************************/
  24. package com.v2gclarity.risev2g.shared.messageHandling;
  25. import com.v2gclarity.risev2g.shared.misc.State;
  26. import com.v2gclarity.risev2g.shared.misc.TimeRestrictions;
  27. /**
  28. * There are four possible outcomes of processing an incoming message at the respective state
  29. * 1. The server generates a response message to a processed request message
  30. * 2. The client generates a new request message following a processed response message
  31. * 3. Either side switches to another state which shall process the incoming message
  32. * 4. The message cannot be processed at this state -> terminate session
  33. */
  34. public class SendMessage extends ReactionToIncomingMessage {
  35. private Object payload;
  36. private boolean supportedAppProtocolHandshake;
  37. private State nextState;
  38. private int timeout;
  39. public SendMessage(Object payload, State newState) {
  40. this(payload, false, newState, TimeRestrictions.V2G_SECC_SEQUENCE_TIMEOUT);
  41. }
  42. public SendMessage(Object payload, State newState, int timeout) {
  43. this(payload, false, newState, timeout);
  44. }
  45. /**
  46. * Similar to the constructor which has a timeout, except that the server has only one timeout,
  47. * namely the V2G_Message_Sequence_Timeout, which is message independent and does not need
  48. * to be provided additionally.
  49. *
  50. * @param payload
  51. * @param supportedAppProtocolHandshake
  52. * @param nextState
  53. * @param stopV2GCommunicationSession
  54. */
  55. public SendMessage(Object payload, boolean supportedAppProtocolHandshake, State nextState) {
  56. this(payload, supportedAppProtocolHandshake, nextState, TimeRestrictions.V2G_SECC_SEQUENCE_TIMEOUT);
  57. }
  58. public SendMessage(
  59. Object payload,
  60. boolean supportedAppProtocolHandshake,
  61. State nextState,
  62. int timeout) {
  63. super();
  64. this.payload = payload;
  65. this.supportedAppProtocolHandshake = supportedAppProtocolHandshake;
  66. this.nextState = nextState;
  67. this.timeout = timeout;
  68. }
  69. public Object getPayload() {
  70. return payload;
  71. }
  72. public boolean isSupportedAppProtocolHandshake() {
  73. return supportedAppProtocolHandshake;
  74. }
  75. public State getNextState() {
  76. return nextState;
  77. }
  78. public int getTimeout() {
  79. return timeout;
  80. }
  81. }