com.sun.sgs.app
Interface ClientSessionListener


public interface ClientSessionListener

Listener for messages sent from an associated client session to the server.

An implementation of a ClientSessionListener should implement the Serializable interface, so that session listeners can be stored persistently. If a given listener has mutable state, that listener should also implement the ManagedObject interface.

The methods of this listener are called within the context of a Task being executed by the TaskManager. If, during such an execution, a task invokes one of this listener's methods and that method throws an exception, that exception implements ExceptionRetryStatus, and its shouldRetry method returns true, then the TaskManager will make further attempts to retry the task that invoked the listener's method. It will continue those attempts until either an attempt succeeds or it notices an exception is thrown that is not retryable.

For a full description of task execution behavior, see the documentation for TaskManager.scheduleTask(Task).


Method Summary
 void disconnected(boolean graceful)
          Notifies this listener that the associated session's client has disconnected.
 void receivedMessage(ByteBuffer message)
          Notifies this listener that the specified message, sent by the associated session's client, was received.
 

Method Detail

receivedMessage

void receivedMessage(ByteBuffer message)
Notifies this listener that the specified message, sent by the associated session's client, was received.

If this listener needs to delay processing the given message for any reason, including until more resources become available, this listener may throw MessageRejectedException. If this listener does throw MessageRejectedException, it will be as if this invocation never happened; that is, the transaction associated with this invocation is aborted, so it is not possible to save any partial processing result before MessageRejectedException is thrown.

Parameters:
message - a message
Throws:
MessageRejectedException - if there are not enough resources to process the specified message

disconnected

void disconnected(boolean graceful)
Notifies this listener that the associated session's client has disconnected. If graceful is true, then the session's client logged out gracefully; otherwise, the session was either disconnected forcibly by the server or disconnected due to other factors such as communication failure.

If this listener does not implement ManagedObject, it will be removed from the persistent store after this method returns. Otherwise, this listener will remain in the persistent store until it is explicitly removed.

When this method is invoked, the client session associated with this listener will have already been removed if the application removed the client session in order to disconnect it. If the client session has not yet been removed and this method does not remove the client session, the client session will be removed in the same transaction after this method returns.

Parameters:
graceful - if true, the specified client session logged out gracefully

Project Darkstar, Version 0.9.9.6
2009-05-08 15:39:40

Copyright © 2007-2009 Sun Microsystems, Inc. All rights reserved