#include <commcenter.h>
Collaboration diagram for CommCenter:
Public Methods | |
CommCenter () | |
~CommCenter () | |
void | loop () |
void | getMessages () |
Client * | getClientForMigration (string name) |
Protected Methods | |
New Conections | |
Methods to create new conections, or wait if there is not pending conection | |
void | newClient () |
void | newGraphicClient () |
void | newControlClient () |
void | newServer () |
Parts of the Main Thread Loop | |
The main loop makes several tasks. Each of this methos is one of these tasks | |
void | checkForConections () |
void | checkForDeadClients () |
void | removeDeadClients () |
void | waitForClients () |
void | makeMovements () |
Protected Attributes | |
vector< baseClient * > | clients |
World * | world |
The world that this commcenter controls. | |
map< string, vector< Client * >, less< string > > | clientMap |
A dictionary of name of AgentClients and lists of AgentClients. | |
Ports | |
Ports that wait for incomming connections, that later are redirected to channels | |
ost::TCPSocket * | clientPort |
ost::TCPSocket * | graphicClientPort |
ost::TCPSocket * | controlClientPort |
ost::TCPSocket * | serverPort |
Definition at line 47 of file commcenter.h.
|
Creates the communication center. It opens several ports to accept incomming conections; these ports include: * client port (2002) * graphic client port (3003) * control client port (3004) * server port (8888) Definition at line 46 of file commcenter.cc. References clientPort, controlClientPort, graphicClientPort, log, serverPort, and world. |
|
Destroys the comm center; the open ports are closed. Definition at line 70 of file commcenter.cc. References clientPort, clients, controlClientPort, graphicClientPort, log, and serverPort. |
|
Checks if there are new conections on any of the client ports, or in the server port, and creates the threads and clients Definition at line 153 of file commcenter.cc. References clientPort, controlClientPort, graphicClientPort, newClient(), newControlClient(), newGraphicClient(), newServer(), and serverPort. Referenced by loop(). |
|
Checks if there are dead clients, and decrements the numClients to wait Definition at line 164 of file commcenter.cc. References clients, World::numClients, and world. Referenced by waitForClients(). |
|
Searches a suitable client for migration of an agent Actually it does it selecting one pseudo-random agentClient from the list of clients with the same name of actual agent Definition at line 222 of file commcenter.cc. References clientMap, and log. Referenced by World::newAgent(). |
|
|
|
Loops thruogh the open ports to check for new conections; if one appears the correct handler is called Definition at line 93 of file commcenter.cc. References andTimePasses(), checkForConections(), clients, World::getQuit(), log, makeMovements(), waitForClients(), and world. |
|
Make the movements done Definition at line 212 of file commcenter.cc. References World::step(), and world. Referenced by loop(). |
|
Creates a new client, and starts it. Definition at line 112 of file commcenter.cc. References clientMap, clientPort, clients, Client::getName(), and world. Referenced by checkForConections(). |
|
Creates a new control client, and starts it. Definition at line 135 of file commcenter.cc. References clients, controlClientPort, and world. Referenced by checkForConections(). |
|
Creates a new graphic client, starts it, and stop it's execution (I can ensure that it's safe to let it run any time before dontWalk is issued Definition at line 126 of file commcenter.cc. References clients, graphicClientPort, and world. Referenced by checkForConections(). |
|
Creates a new server channel, and starts it. Definition at line 144 of file commcenter.cc. References log. Referenced by checkForConections(). |
|
Deletes not Alive clients Definition at line 174 of file commcenter.cc. References clients. Referenced by waitForClients(). |
|
Waits till all clients have finished the run cycle Definition at line 186 of file commcenter.cc. References checkForDeadClients(), clients, World::numClients, removeDeadClients(), and world. Referenced by loop(). |
|
A dictionary of name of AgentClients and lists of AgentClients.
Definition at line 90 of file commcenter.h. Referenced by getClientForMigration(), and newClient(). |
|
Definition at line 55 of file commcenter.h. Referenced by checkForConections(), CommCenter(), newClient(), and ~CommCenter(). |
|
Definition at line 61 of file commcenter.h. Referenced by checkForDeadClients(), loop(), newClient(), newControlClient(), newGraphicClient(), removeDeadClients(), waitForClients(), and ~CommCenter(). |
|
Definition at line 57 of file commcenter.h. Referenced by checkForConections(), CommCenter(), newControlClient(), and ~CommCenter(). |
|
Definition at line 56 of file commcenter.h. Referenced by checkForConections(), CommCenter(), newGraphicClient(), and ~CommCenter(). |
|
Definition at line 58 of file commcenter.h. Referenced by checkForConections(), CommCenter(), and ~CommCenter(). |
|
The world that this commcenter controls.
Definition at line 88 of file commcenter.h. Referenced by checkForDeadClients(), CommCenter(), loop(), makeMovements(), newClient(), newControlClient(), newGraphicClient(), and waitForClients(). |