flex.messaging
Class MessageClient

java.lang.Object
  extended by flex.messaging.util.TimeoutAbstractObject
      extended by flex.messaging.MessageClient
All Implemented Interfaces:
Serializable

public class MessageClient
extends TimeoutAbstractObject
implements Serializable

Represents a client-side MessageAgent instance. Currently a server-side MessageClient is only created if its client-side counterpart has subscribed to a destination for pushed data (e.g. Consumer). Client-side Producers do not result in the creation of corresponding server-side MessageClient instances. Client-side MessageAgents communicate with the server over a Channel that corresponds to a FlexSession. Server-side MessageClient instances are always created in the context of a FlexSession and when the FlexSession is invalidated any associated MessageClients are invalidated as well. MessageClients may also be timed out on a per-destination basis and this is based on subscription inactivity. If no messages are pushed to the MessageClient within the destination's subscription timeout period the MessageClient will be shutdown even if the associated FlexSession is still active and connected. Per-destination subscription timeout is an optional configuration setting, and should only be used when inactive subscriptions should be shut down opportunistically to preserve server resources.

See Also:
Serialized Form

Field Summary
static String MESSAGE_CLIENT_LOG_CATEGORY
          Log category for MessageClient related messages.
 
Method Summary
static void addMessageClientCreatedListener(MessageClientListener listener)
          Adds a MessageClient created listener.
 void addMessageClientDestroyedListener(MessageClientListener listener)
          Adds a MessageClient destroy listener.
 Object getClientId()
          Returns the clientId for the MessageClient.
 String getDestinationId()
          Returns the destination the MessageClient is subscribed to.
 String getEndpointId()
          Returns the Id for the endpoint the MessageClient subscription was created over.
 FlexClient getFlexClient()
          Returns the FlexClient associated with this MessageClient.
 FlexSession getFlexSession()
          Returns the FlexSession associated with this MessageClient.
 int getSubscriptionCount()
          Returns the number of subscriptions associated with this MessageClient.
 void invalidate()
          Invalidates the MessageClient.
 void invalidate(boolean notifyClient)
          Invalidates the MessageClient, and optionally attempts to notify the client that this subscription has been invalidated.
 void invalidate(Message message)
          Pushes the supplied message and then invalidates the MessageClient.
 boolean isValid()
          Returns true if the MessageClient is valid; false if it has been invalidated.
static void removeMessageClientCreatedListener(MessageClientListener listener)
          Removes a MessageClient created listener.
 void removeMessageClientDestroyedListener(MessageClientListener listener)
          Removes a MessageClient destroyed listener.
 
Methods inherited from class flex.messaging.util.TimeoutAbstractObject
cancelTimeout, getLastUse, getTimeoutFuture, getTimeoutManager, getTimeoutPeriod, getTimeoutTask, setLastUse, setTimeoutFuture, setTimeoutManager, setTimeoutPeriod, setTimeoutTask, updateLastUse
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_CLIENT_LOG_CATEGORY

public static final String MESSAGE_CLIENT_LOG_CATEGORY
Log category for MessageClient related messages.

See Also:
Constant Field Values
Method Detail

addMessageClientCreatedListener

public static void addMessageClientCreatedListener(MessageClientListener listener)
Adds a MessageClient created listener.

Parameters:
listener - The listener to add.
See Also:
MessageClientListener

removeMessageClientCreatedListener

public static void removeMessageClientCreatedListener(MessageClientListener listener)
Removes a MessageClient created listener.

Parameters:
listener - The listener to remove.
See Also:
MessageClientListener

getClientId

public Object getClientId()
Returns the clientId for the MessageClient.

Returns:
The clientId for the MessageClient.

getDestinationId

public String getDestinationId()
Returns the destination the MessageClient is subscribed to.

Returns:
The destination the MessageClient is subscribed to.

getEndpointId

public String getEndpointId()
Returns the Id for the endpoint the MessageClient subscription was created over.

Returns:
The Id for the endpoint the MessageClient subscription was created over.

getFlexClient

public FlexClient getFlexClient()
Returns the FlexClient associated with this MessageClient.

Returns:
The FlexClient assocaited with this MessageClient.

getFlexSession

public FlexSession getFlexSession()
Returns the FlexSession associated with this MessageClient.

Returns:
The FlexSession associated with this MessageClient.

getSubscriptionCount

public int getSubscriptionCount()
Returns the number of subscriptions associated with this MessageClient.

Returns:
The number of subscriptions associated with this MessageClient.

addMessageClientDestroyedListener

public void addMessageClientDestroyedListener(MessageClientListener listener)
Adds a MessageClient destroy listener.

Parameters:
listener - The listener to add.
See Also:
MessageClientListener

removeMessageClientDestroyedListener

public void removeMessageClientDestroyedListener(MessageClientListener listener)
Removes a MessageClient destroyed listener.

Parameters:
listener - The listener to remove.
See Also:
MessageClientListener

isValid

public boolean isValid()
Returns true if the MessageClient is valid; false if it has been invalidated.

Returns:
true if the MessageClient is valid; otherwise false.

invalidate

public void invalidate()
Invalidates the MessageClient.


invalidate

public void invalidate(boolean notifyClient)
Invalidates the MessageClient, and optionally attempts to notify the client that this subscription has been invalidated. This overload is used when a subscription is timed out while the client is still actively connected to the server but should also be used by any custom code on the server that invalidates MessageClients but wishes to notify the client cleanly.

Parameters:
notifyClient - true to notify the client that its subscription has been invalidated.

invalidate

public void invalidate(Message message)
Pushes the supplied message and then invalidates the MessageClient.

Parameters:
message - The message to push to the client before invalidating. When message is null, MessageClient is invalidated silently.


Copyright © 2008 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/MessageClient.html