com.sun.sgs.client
Interface ServerSession

All Known Implementing Classes:
SimpleClient

public interface ServerSession

Represents a client's view of a login session with the server. Each time a client logs in, it will be assigned a different server session. A client can use its ServerSession to send messages to the server, to check if it is connected, or to log out.

A server session has an associated ServerSessionListener that is notified of session communication events such as message receipt, channel joins, reconnection, or disconnection. Once a server session is 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
 boolean isConnected()
          Returns true if this session is connected, otherwise returns false.
 void logout(boolean force)
          Initiates logging out from the server.
 void send(ByteBuffer message)
          Sends the message contained in the specified ByteBuffer to the server.
 

Method Detail

send

void send(ByteBuffer message)
          throws IOException
Sends the message contained in the specified ByteBuffer to the server. The message starts at the buffer's current position and ends at the buffer's limit. The buffer's position is not modified by this operation. The specified message is sent asynchronously to the server; therefore, a successful invocation of this method does not indicate that the given message was successfully sent. Messages that are received by the server are delivered in sending order.

The ByteBuffer may be reused immediately after this method returns. Changes made to the buffer after this method returns will have no effect on the message sent to the server by this invocation.

Parameters:
message - a message
Throws:
IOException - if this session is disconnected or an IO error occurs
IllegalStateException - if the client is not in an appropriate state (suspended, for example) to send a message

isConnected

boolean isConnected()
Returns true if this session is connected, otherwise returns false.

Returns:
true if this session is connected, and false otherwise

logout

void logout(boolean force)
Initiates logging out from the server. If force is true then this session is forcibly terminated, for example, by terminating the associated client's network connections. If force is false, then this session is gracefully disconnected, notifying the server that the client logged out. When a session has been logged out, gracefully or otherwise, the disconnected method is invoked on this session's associated ServerSessionListener passing a boolean indicating whether the disconnection was graceful.

If this server session is already disconnected, then an IllegalStateException is thrown.

Parameters:
force - if true, this session is forcibly terminated; otherwise the session is gracefully disconnected
Throws:
IllegalStateException - if this session is disconnected

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