com.sun.sgs.client.lightweight
Class LightweightClient

java.lang.Object
  extended by com.sun.sgs.client.lightweight.LightweightClient
All Implemented Interfaces:
ServerSession

public final class LightweightClient
extends Object
implements ServerSession

Lightweight implementation that manages a single client connection. Note that this implements a singleton connector, so that all connections from this VM will be routed through the same LightweightConnector, but this would be easy to change for a more robust stress-testing client.


Constructor Summary
LightweightClient(SimpleClientListener listener)
          Creates an instance of LightweightClient.
 
Method Summary
 boolean isConnected()
          Returns true if this session is connected, otherwise returns false.
 void login(Properties p)
          Initiates a login session with the server.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LightweightClient

public LightweightClient(SimpleClientListener listener)
Creates an instance of LightweightClient.

Method Detail

login

public void login(Properties p)
           throws IOException
Description copied from interface: ServerSession
Initiates a login session with the server. The use of properties parameter is implementation specific.

Specified by:
login in interface ServerSession
Parameters:
p - the implementation specific connection properties to use in creating the client's session
Throws:
IOException

send

public void send(ByteBuffer message)
          throws IOException
Description copied from interface: ServerSession
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.

Specified by:
send in interface ServerSession
Parameters:
message - a message
Throws:
IOException - if this session is disconnected or an IO error occurs

isConnected

public boolean isConnected()
Description copied from interface: ServerSession
Returns true if this session is connected, otherwise returns false.

Specified by:
isConnected in interface ServerSession
Returns:
true if this session is connected, and false otherwise

logout

public void logout(boolean force)
Description copied from interface: ServerSession
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.

Specified by:
logout in interface ServerSession
Parameters:
force - if true, this session is forcibly terminated; otherwise the session is gracefully disconnected

Project Darkstar, Version 0.9.8-SNAPSHOT
2013-07-29 20:21:26

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