soc.server
Class SOCLocalRobotClient

java.lang.Object
  extended by soc.server.SOCLocalRobotClient
All Implemented Interfaces:
java.lang.Runnable

 class SOCLocalRobotClient
extends java.lang.Object
implements java.lang.Runnable

Each local robot in the SOCServer gets its own client thread. Equivalent to main thread in SOCRobotClient in network games.

This class was originally SOCPlayerClient.SOCPlayerLocalRobotRunner, then moved in 1.1.09 to SOCServer.SOCPlayerLocalRobotRunner, Split out in 2.0.00 to its own top-level class. Before 2.0.00, the thread name prefix was robotrunner- not localrobotclient-.

Since:
1.1.00
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
SOCServer.setupLocalRobots(int, int)

Field Summary
(package private)  SOCRobotClient rob
          This bot's client in robotClients.
static java.util.Hashtable<java.lang.String,SOCRobotClient> robotClients
          All the started SOCRobotClients.
 
Constructor Summary
protected SOCLocalRobotClient(SOCRobotClient rc)
           
 
Method Summary
static void createAndStartRobotClientThread(java.lang.String rname, java.lang.String strSocketName, int port, java.lang.String cookie)
          Create and start a robot client within a SOCLocalRobotClient thread.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

robotClients

public static java.util.Hashtable<java.lang.String,SOCRobotClient> robotClients
All the started SOCRobotClients. Key is the bot nickname.

Note: If a bot is disconnected from the server, it's not removed from this list, because the same bot will try to reconnect. To see if a bot is connected, check SOCServer.robots instead.

Since:
1.1.13

rob

final SOCRobotClient rob
This bot's client in robotClients.

Constructor Detail

SOCLocalRobotClient

protected SOCLocalRobotClient(SOCRobotClient rc)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

createAndStartRobotClientThread

public static void createAndStartRobotClientThread(java.lang.String rname,
                                                   java.lang.String strSocketName,
                                                   int port,
                                                   java.lang.String cookie)
                                            throws java.lang.ClassNotFoundException,
                                                   java.lang.LinkageError
Create and start a robot client within a SOCLocalRobotClient thread. After creating it, yield the current thread and then sleep 75 milliseconds, to give the robot time to start itself up. The SOCPlayerLocalRobotRunner's run() will add the SOCRobotClient to robotClients.

Parameters:
rname - Name of robot
strSocketName - Server's stringport socket name, or null
port - Server's tcp port, if strSocketName is null
cookie - Cookie for robot connections to server
Throws:
java.lang.ClassNotFoundException - if a robot class, or SOCDisplaylessClient, can't be loaded. This can happen due to packaging of the server-only JAR.
java.lang.LinkageError - for same reason as ClassNotFoundException
Since:
1.1.09
See Also:
SOCServer.setupLocalRobots(int, int)