com.sun.sgs.client
Interface ServerSessionListener

All Known Subinterfaces:
SimpleClientListener

public interface ServerSessionListener

A client's listener for handling messages sent from server to client and for handling other connection-related events.

A ServerSessionListener for a client is notified in the following cases: when the associated client is joined to a channel (joinedChannel), a message is received from the server (receivedMessage), a connection with the server is being re-established (reconnecting), a connection has been re-established (reconnected), or finally when the associated server session becomes disconnected, gracefully or otherwise (disconnected).

If a server session becomes disconnected, it can no longer be used to send messages to the server. In this case, a client must log in again to obtain a new server session to communicate with the server.


Method Summary
 void disconnected(boolean graceful, String reason)
          Notifies this listener that the associated server session is disconnected.
 ClientChannelListener joinedChannel(ClientChannel channel)
          Notifies this listener that its associated client has joined the specified channel, and returns a non-null ClientChannelListener for that channel.
 void receivedMessage(ByteBuffer message)
          Notifies this listener that the specified message was sent by the server.
 void reconnected()
          Notifies this listener when the associated server session is successfully reconnected.
 void reconnecting()
          Notifies this listener that requests to the server must be suspended.
 

Method Detail

joinedChannel

ClientChannelListener joinedChannel(ClientChannel channel)
Notifies this listener that its associated client has joined the specified channel, and returns a non-null ClientChannelListener for that channel.

When a message is received on the specified channel, the returned listener's receivedMessage method is invoked with the specified channel and the message. The returned listener is notified of messages that its client sends on the specified channel; that is, a sender receives its own broadcasts.

When the client associated with this server session leaves the specified channel, the returned listener's leftChannel method is invoked with the specified channel.

Parameters:
channel - a channel
Returns:
a non-null listener for the specified channel

receivedMessage

void receivedMessage(ByteBuffer message)
Notifies this listener that the specified message was sent by the server.

Parameters:
message - a read-only ByteBuffer containing the message

reconnecting

void reconnecting()
Notifies this listener that requests to the server must be suspended. The associated server session may be reconnecting with the same server or another server, or its requests may be temporarily suspended.

Once this method returns, the associated server session should not send any messages to the server until this listener's reconnected method is invoked. Any messages sent during message suspension and/or server reconnection are not guaranteed to be received and/or processed by the server.

If the associated server session is reconnecting and a connection can be re-established with the server in a timely manner, this listener's reconnected method will be invoked. Otherwise, if a connection cannot be re-established, this listener's disconnected method will be invoked with false indicating that the associated session is disconnected from the server and the client must log in again.


reconnected

void reconnected()
Notifies this listener when the associated server session is successfully reconnected. After this method is invoked, the associated session can resume sending messages to the server.


disconnected

void disconnected(boolean graceful,
                  String reason)
Notifies this listener that the associated server session is disconnected.

If graceful is true, the disconnection was due to the associated client gracefully logging out; otherwise, the disconnection was due to other circumstances, such as forced disconnection.

Before this method is invoked, it is guaranteed that the listeners of all ClientChannels with this session as a member will have their leftChannel methods invoked.

Parameters:
graceful - true if disconnection was due to the associated client gracefully logging out, and false otherwise
reason - a string indicating the reason this session was disconnected, or null if no reason was provided

RedDwarf, Version 0.10.0
2010-02-12 09:11:07

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved