|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--simulator.Server
Implements a base function of a server as a thread. To use this class, you must extend it like this:
class MyServer extends Server{
public MyServer(String argv[]) {
super(argv); // this is the constructor that call the super
}
protected void init() {
// initialize all undefined variable
about="Server ...";
resolutionTime=100;
printerTime=100;
agentsTime=300;
timeToSend=4;
GSV=new MySendVRML; //this is the implementation of GenericSendVRML
GSA=new MyServerAmbient; //this is the implementation of GenericServerAmbient
staticAmb=new MyAmbient(); //this is the implementation of Ambient
ExitClientCommand C1=new ExitClientCommand();
clientCommands.put(C1.getName(),C1); //insert the client commands
...
}
public static void main(String[] argv){
new MyServer(argv);
}
}
How you must see your class must only initilize all the undefined variables and creates your object that performes your commands (refer to the other abstract class for details) for the simulation.
SendVRML
,
GenericSendVRML
,
ServerAmbient
,
GenericServerAmbient
,
Connection
,
Ambient
Field Summary | |
static java.lang.String |
about
This is undefined string avoided to contain the about information of server program. |
static int |
agentsTime
This is undefined integer avoided to contain the time to resume the agents. |
protected Semaphore[] |
availableCells
This is the array of semaphore that contains the available resources of the index-array type |
protected java.util.Hashtable |
clientCommands
Contains the list of commands that the client can execute. |
protected java.util.Hashtable |
connectedUsers
Contains the list of client users that are connected |
static int |
DEFAULT_PORT
|
static int |
dimQueue
Max dimension for the queue |
protected ProcessesHandler |
GP
Contains the time handler of processes |
static GenericServerAmbient |
GSA
This is undefined process that is to be used with ServerAmbient |
static GenericSendVRML |
GSV
This is undefined process that is to be used with SendVRML |
static int |
maxNumProc
|
protected java.util.Hashtable |
nodesList
Contains the list of nodes of virtual world |
protected int |
port
contains the port number uses to create a connection with socket |
protected Semaphore[] |
presentMessage
This is the array of semaphore that contains the occupied resources of the index-array type |
static int |
printerTime
This is undefined integer avoided to contain the time to resume the printer process. |
protected java.util.Hashtable |
processesList
Contains the list of agents processes |
protected Queue[] |
processesQueue
A queue of message changed by client agents and the server |
static int |
realTime
This variable set the real time in the simulation with a 1 value. |
static int |
resolutionTime
This is undefined integer avoided to contain the resolution of the time processes handler |
protected ServerAmbient |
SA
Contains the process for serving an ambient |
protected java.net.ServerSocket |
server_socket
Contains the server socket istance to permit the comunication |
protected java.util.Hashtable |
state
Contains instance of the actual states of agents |
protected Ambient |
staticAmb
This is the abstract class to build your static ambient |
protected SendVRML |
SV
This is the thread that updates the simulator state and send the VRML view to the client |
int |
timeToSend
Indicate how many times we must attend before send a vrml scene to client. |
Fields inherited from class java.lang.Thread |
contextClassLoader,
daemon,
eetop,
group,
inheritedAccessControlContext,
MAX_PRIORITY,
MIN_PRIORITY,
name,
NORM_PRIORITY,
priority,
single_step,
stillborn,
stopThreadPermission,
target,
threadInitNumber,
threadQ,
values |
Constructor Summary | |
Server(java.lang.String[] args)
Analize the command passes as string |
Method Summary | |
static void |
fail(java.lang.Exception e,
java.lang.String msg)
Print fail information and exit from server program |
static void |
helpScreen()
Display a help screen |
protected abstract void |
init()
This abstract method must be implemented by the derived class. |
void |
run()
Execute the server thread: listen for a client connection and made it The priority of this thread is set to MIN_PRIORITY by the default contructor. |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static java.lang.String about
public static int realTime
resolutionTime
is 100msec. and this is set to
3, this implies that we update the simulation event us 100msec was departed, but
this is made in 300msec, so slow system can execute correctly the simulation even
if no real time is performed.public static int resolutionTime
public static int printerTime
resolutionTime
variable.public static int agentsTime
resolutionTime
variable.public int timeToSend
printerTime*timeToSend
ProcessesHandler.printerTime
public static GenericSendVRML GSV
SendVRML
public static GenericServerAmbient GSA
ServerAmbient
public static final int DEFAULT_PORT
public static final int maxNumProc
public static final int dimQueue
protected int port
protected java.net.ServerSocket server_socket
protected java.util.Hashtable connectedUsers
protected java.util.Hashtable nodesList
protected java.util.Hashtable processesList
protected ServerAmbient SA
protected ProcessesHandler GP
protected SendVRML SV
protected Semaphore[] availableCells
protected Semaphore[] presentMessage
protected Queue[] processesQueue
protected Ambient staticAmb
protected java.util.Hashtable state
protected java.util.Hashtable clientCommands
Constructor Detail |
public Server(java.lang.String[] args)
args
- string that contain the server initial parametersMethod Detail |
protected abstract void init()
Server
constructor to permits to
define the elements that are not initialized.
So the derived class may have a constructor that calls Server's
and the late bilding process calls your just defined init
.public static void helpScreen()
public void run()
public static void fail(java.lang.Exception e, java.lang.String msg)
e
- the exception that fails servermsg
- the message to print in err file
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |