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 whether the associated server session is successfully reconnected.
 void reconnecting()
          Notifies this listener that its associated server session is in the process of reconnecting with the server.
 

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 its associated server session is in the process of reconnecting with the server.

If 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 whether the associated server session is successfully reconnected.


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

Project Darkstar, Version 0.9.9
2013-07-29 20:40:00

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