You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PushConnection.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.communication;
  17. import com.google.gwt.user.client.Command;
  18. import com.vaadin.client.ApplicationConnection;
  19. import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler;
  20. import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
  21. /**
  22. * Represents the client-side endpoint of a bidirectional ("push") communication
  23. * channel. Can be used to send UIDL request messages to the server and to
  24. * receive UIDL messages from the server (either asynchronously or as a response
  25. * to a UIDL request.) Delegates the UIDL handling to the
  26. * {@link ApplicationConnection}.
  27. *
  28. * @author Vaadin Ltd
  29. * @since 7.1
  30. */
  31. public interface PushConnection {
  32. /**
  33. * Two-phase construction to allow using GWT.create().
  34. *
  35. * @param connection
  36. * The ApplicationConnection
  37. */
  38. public void init(ApplicationConnection connection,
  39. PushConfigurationState pushConfigurationState,
  40. CommunicationErrorHandler errorHandler);
  41. /**
  42. * Pushes a message to the server. Will throw an exception if the connection
  43. * is not active (see {@link #isActive()}).
  44. * <p>
  45. * Implementation detail: The implementation is responsible for queuing
  46. * messages that are pushed after {@link #init(ApplicationConnection)} has
  47. * been called but before the connection has internally been set up and then
  48. * replay those messages in the original order when the connection has been
  49. * established.
  50. *
  51. * @param message
  52. * the message to push
  53. * @throws IllegalStateException
  54. * if this connection is not active
  55. *
  56. * @see #isActive()
  57. */
  58. public void push(String message);
  59. /**
  60. * Checks whether this push connection is in a state where it can push
  61. * messages to the server. A connection is active until
  62. * {@link #disconnect(Command)} has been called.
  63. *
  64. * @return <code>true</code> if this connection can accept new messages;
  65. * <code>false</code> if this connection is disconnected or
  66. * disconnecting.
  67. */
  68. public boolean isActive();
  69. /**
  70. * Closes the push connection. To ensure correct message delivery order, new
  71. * messages should not be sent using any other channel until it has been
  72. * confirmed that all messages pending for this connection have been
  73. * delivered. The provided command callback is invoked when messages can be
  74. * passed using some other communication channel.
  75. * <p>
  76. * After this method has been called, {@link #isActive()} returns
  77. * <code>false</code>. Calling this method for a connection that is no
  78. * longer active will throw an exception.
  79. *
  80. * @param command
  81. * callback command invoked when the connection has been properly
  82. * disconnected
  83. * @throws IllegalStateException
  84. * if this connection is not active
  85. */
  86. public void disconnect(Command command);
  87. /**
  88. * Returns a human readable string representation of the transport type used
  89. * to communicate with the server.
  90. *
  91. * @since 7.1
  92. * @return A human readable string representation of the transport type
  93. */
  94. public String getTransportType();
  95. }