com.sun.sgs.app
Interface ChannelListener


public interface ChannelListener

Listener for messages received on a channel. A channel can be created with a ChannelListener which is notified when any client session sends a message on that channel.

An implementation of a ChannelListener should implement the Serializable interface, so that channel 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 receivedMessage(Channel channel, ClientSession sender, ByteBuffer message)
          Notifies this listener that the given message is being sent by the specified sender on the given channel.
 

Method Detail

receivedMessage

void receivedMessage(Channel channel,
                     ClientSession sender,
                     ByteBuffer message)
Notifies this listener that the given message is being sent by the specified sender on the given channel. The caller of this method does not automatically forward the message to the channel for delivery. If forwarding the message to the channel is desired, the listener is responsible for doing so.

Depending on application-specific requirements, this listener may take action, which is not limited to, but may include the following: sending the message "as is" to the channel, sending alternate or additional messages with or without the specified message content, or ignoring the message.

Parameters:
channel - a channel
sender - the sending client session
message - a message

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

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