com.sun.sgs.example.request.client
Class WandererClient

java.lang.Object
  extended by com.sun.sgs.example.request.client.WandererClient
All Implemented Interfaces:
com.sun.sgs.client.ClientChannelListener, com.sun.sgs.client.ServerSessionListener, com.sun.sgs.client.simple.SimpleClientListener, Runnable

public class WandererClient
extends Object
implements Runnable, com.sun.sgs.client.simple.SimpleClientListener, com.sun.sgs.client.ClientChannelListener

Defines a client that uses the RequestApp application to simulate a game with wandering players.

Each WandererClient steps randomly around a board, sending messages to the channel associated with its local neighborhood, and reading and writing values associated with its current location. The resulting application serves as a stress test for the channel and data services, performing operations that each include a channel send, and twice as many data service reads as writes.

Clients can handle disconnects, and the main method arranges to run multiple clients.

This class supports the following properties:

This class uses the Logger named com.sun.sgs.example.request.client.wanderer to log at the following levels:


Constructor Summary
WandererClient()
          Creates an instance, and starts a thread to login and perform actions.
 
Method Summary
 void disconnected(boolean graceful, String reason)
          
 PasswordAuthentication getPasswordAuthentication()
          
 com.sun.sgs.client.ClientChannelListener joinedChannel(com.sun.sgs.client.ClientChannel channel)
          
 void leftChannel(com.sun.sgs.client.ClientChannel channel)
          
 void loggedIn()
          
 void loginFailed(String reason)
          
static void main(String[] args)
          Starts up clients.
 void receivedMessage(ByteBuffer message)
          
 void receivedMessage(com.sun.sgs.client.ClientChannel channel, ByteBuffer message)
          
 void reconnected()
          
 void reconnecting()
          
 void run()
          Performs client actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WandererClient

public WandererClient()
Creates an instance, and starts a thread to login and perform actions.

Method Detail

main

public static void main(String[] args)
Starts up clients.

Parameters:
args - ignored

run

public void run()
Performs client actions.

Specified by:
run in interface Runnable

getPasswordAuthentication

public PasswordAuthentication getPasswordAuthentication()

This implementation returns password authentication for the current user.

Specified by:
getPasswordAuthentication in interface com.sun.sgs.client.simple.SimpleClientListener

loggedIn

public void loggedIn()

This implementation notifies the client thread that the client is active.

Specified by:
loggedIn in interface com.sun.sgs.client.simple.SimpleClientListener

loginFailed

public void loginFailed(String reason)

Specified by:
loginFailed in interface com.sun.sgs.client.simple.SimpleClientListener

receivedMessage

public void receivedMessage(ByteBuffer message)

Specified by:
receivedMessage in interface com.sun.sgs.client.ServerSessionListener

reconnecting

public void reconnecting()

Specified by:
reconnecting in interface com.sun.sgs.client.ServerSessionListener

reconnected

public void reconnected()

Specified by:
reconnected in interface com.sun.sgs.client.ServerSessionListener

disconnected

public void disconnected(boolean graceful,
                         String reason)

Specified by:
disconnected in interface com.sun.sgs.client.ServerSessionListener

joinedChannel

public com.sun.sgs.client.ClientChannelListener joinedChannel(com.sun.sgs.client.ClientChannel channel)

Specified by:
joinedChannel in interface com.sun.sgs.client.ServerSessionListener

leftChannel

public void leftChannel(com.sun.sgs.client.ClientChannel channel)

Specified by:
leftChannel in interface com.sun.sgs.client.ClientChannelListener

receivedMessage

public void receivedMessage(com.sun.sgs.client.ClientChannel channel,
                            ByteBuffer message)

Specified by:
receivedMessage in interface com.sun.sgs.client.ClientChannelListener


Copyright © 2013. All Rights Reserved.