Package com.vaadin.client.communication
Class ServerRpcQueue
- java.lang.Object
-
- com.vaadin.client.communication.ServerRpcQueue
-
public class ServerRpcQueue extends Object
Manages the queue of server invocations (RPC) which are waiting to be sent to the server.- Since:
- 7.6
- Author:
- Vaadin Ltd
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationConnection
connection
-
Constructor Summary
Constructors Constructor Description ServerRpcQueue()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(MethodInvocation invocation, boolean lastOnly)
Adds an explicit RPC method invocation to the send queue.void
clear()
Clears the queuevoid
flush()
Triggers a send of server RPC and legacy variable changes to the server.static ServerRpcQueue
get(ApplicationConnection connection)
Returns the server RPC queue for the given applicationCollection<MethodInvocation>
getAll()
Returns a collection of all queued method invocationsboolean
isEmpty()
Checks if the queue is emptyboolean
isFlushPending()
Checks if a flush operation is pendingstatic boolean
isJavascriptRpc(MethodInvocation invocation)
Checks if the given method invocation originates from Javascriptstatic boolean
isLegacyVariableChange(MethodInvocation invocation)
Checks if the given method invocation represents a Vaadin 6 variable changevoid
removeMatching(MethodInvocation invocation)
Removes any pending invocation of the given method from the queuevoid
setConnection(ApplicationConnection connection)
Sets the application connection this instance is connected to.boolean
showLoadingIndicator()
Checks if a loading indicator should be shown when the RPCs have been sent to the server and we are waiting for a responseint
size()
Returns the current size of the queueJsonArray
toJson()
Returns the current invocations as JSON
-
-
-
Field Detail
-
connection
protected ApplicationConnection connection
-
-
Method Detail
-
setConnection
public void setConnection(ApplicationConnection connection)
Sets the application connection this instance is connected to. Called internally by the framework.- Parameters:
connection
- the application connection this instance is connected to
-
removeMatching
public void removeMatching(MethodInvocation invocation)
Removes any pending invocation of the given method from the queue- Parameters:
invocation
- The invocation to remove
-
add
public void add(MethodInvocation invocation, boolean lastOnly)
Adds an explicit RPC method invocation to the send queue.- Parameters:
invocation
- RPC method invocationdelayed
-false
to trigger sending within a short time window (possibly combining subsequent calls to a single request),true
to let the framework delay sending of RPC calls and variable changes until the next non-delayed changelastOnly
-true
to remove all previously delayed invocations of the same method that were also enqueued with lastonly set totrue
.false
to add invocation to the end of the queue without touching previously enqueued invocations.
-
getAll
public Collection<MethodInvocation> getAll()
Returns a collection of all queued method invocationsThe returned collection must not be modified in any way
- Returns:
- a collection of all queued method invocations
-
clear
public void clear()
Clears the queue
-
size
public int size()
Returns the current size of the queue- Returns:
- the number of invocations in the queue
-
get
public static ServerRpcQueue get(ApplicationConnection connection)
Returns the server RPC queue for the given application- Parameters:
connection
- the application connection which owns the queue- Returns:
- the server rpc queue for the given application
-
isEmpty
public boolean isEmpty()
Checks if the queue is empty- Returns:
- true if the queue is empty, false otherwise
-
flush
public void flush()
Triggers a send of server RPC and legacy variable changes to the server.
-
isFlushPending
public boolean isFlushPending()
Checks if a flush operation is pending- Returns:
- true if a flush is pending, false otherwise
-
showLoadingIndicator
public boolean showLoadingIndicator()
Checks if a loading indicator should be shown when the RPCs have been sent to the server and we are waiting for a response- Returns:
- true if a loading indicator should be shown, false otherwise
-
toJson
public JsonArray toJson()
Returns the current invocations as JSON- Returns:
- the current invocations in a JSON format ready to be sent to the server
-
isJavascriptRpc
public static boolean isJavascriptRpc(MethodInvocation invocation)
Checks if the given method invocation originates from Javascript- Parameters:
invocation
- the invocation to check- Returns:
- true if the method invocation originates from javascript, false otherwise
-
isLegacyVariableChange
public static boolean isLegacyVariableChange(MethodInvocation invocation)
Checks if the given method invocation represents a Vaadin 6 variable change- Parameters:
invocation
- the invocation to check- Returns:
- true if the method invocation is a legacy variable change, false otherwise
-
-