#include <netcontrol.h>
Inheritance diagram for oxygen::NetControl:
Public Types | |
typedef std::map< rcss::net::Addr, boost::shared_ptr< Client > > | TAddrMap |
typedef std::map< rcss::net::Addr, boost::shared_ptr< NetBuffer > > | TBufferMap |
typedef std::list< rcss::net::Addr > | TAddrList |
enum | ESocketType { ST_TCP, ST_UDP } |
Public Member Functions | |
NetControl () | |
virtual | ~NetControl () |
virtual void | InitSimulation () |
creates the managed socket, when the simulation starts | |
virtual void | DoneSimulation () |
called once before the simulation is shut down | |
virtual void | StartCycle () |
called when a new simulation cycle starts, before the simulation is stepped | |
virtual void | EndCycle () |
called when the current simulation cycle ends | |
virtual void | ClientConnect (boost::shared_ptr< Client > client) |
called when a new client connects | |
virtual void | ClientDisconnect (boost::shared_ptr< Client > client) |
called when a client disconnects | |
void | SetServerPort (rcss::net::Addr::PortType port) |
sets the local port, on which connections are accepted | |
rcss::net::Addr::PortType | GetServerPort () |
returns the local port, on which connections are accepted | |
void | SetServerType (ESocketType type) |
sets the type of the socket on which connections are accepted | |
ESocketType | GetServerType () |
returns the type of the socket on which connections are accepted | |
void | SendMessage (boost::shared_ptr< Client > client, const std::string &msg) |
sends a message to the given client | |
void | SendMessage (const rcss::net::Addr &addr, const std::string &msg) |
sends a message to the client with the given address | |
Static Public Member Functions | |
static boost::shared_ptr< rcss::net::Socket > | NetControl::CreateSocket (ESocketType type) |
create a socket according to the given ESocketType | |
Protected Member Functions | |
std::string | NetControl::DescribeSocketType () |
returns a human readable description of the socket type and port | |
void | AcceptTCPConnections () |
checks for and accepts pending TCP connections | |
void | NetControl::ReadMessages () |
reads and stores all available messages | |
void | ReadTCPMessages () |
reads and stores all available TCP messages | |
void | ReadUDPMessages () |
reads and stores all available UDP messages. | |
void | StoreFragment (const rcss::net::Addr &addr, int size) |
copies the message fragment with length | |
void | AddClient (const rcss::net::Addr &from, boost::shared_ptr< rcss::net::Socket > socket=boost::shared_ptr< rcss::net::Socket >()) |
creates a new client entry. | |
void | RemoveClient (const rcss::net::Addr &from) |
removes a client entry and closes the associated socket. | |
void | CloseDeadConnections () |
removes all clients marked in the mCloseClients list | |
Protected Attributes | |
boost::shared_ptr< NetMessage > | mNetMessage |
cached reference to the NetMessage child node | |
rcss::net::Addr | mLocalAddr |
the local port, on which connections are accepted | |
ESocketType | mSocketType |
the type of created socket | |
boost::shared_ptr< rcss::net::Socket > | mSocket |
the socket used to accept connections | |
TAddrMap | mClients |
map of known clients, based on remote address | |
TAddrList | mCloseClients |
list of client connections to be closed | |
TBufferMap | mBuffers |
list of queued messages | |
int | mBufferSize |
the size of the allocated receive buffer | |
boost::shared_array< char > | mBuffer |
the receive buffer | |
int | mClientId |
the next available unique client id | |
Classes | |
struct | Client |
With each simulation cycle it collects all pending client messages in a set of network buffers, each corresponding to a client. It furthes provides methods to send messages to connected clients.
The segmentation of the received data into messages and the composition of messages is delegated to a NetMessage class that is registered to a NetControl node. It is responsible to manage the MetaProtocol, i.e. it adds and removes any additional message framing and type information.
Definition at line 45 of file netcontrol.h.
|
Definition at line 75 of file netcontrol.h. |
|
Definition at line 70 of file netcontrol.h. |
|
Definition at line 73 of file netcontrol.h. |
|
Definition at line 48 of file netcontrol.h. |
|
Definition at line 36 of file netcontrol.cpp. References mBuffer, mBufferSize, mClientId, mLocalAddr, mSocketType, and ST_TCP. |
|
Definition at line 45 of file netcontrol.cpp. |
|
checks for and accepts pending TCP connections
Definition at line 336 of file netcontrol.cpp. References AddClient(), zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetName(), mSocket, mSocketType, and ST_TCP. Referenced by StartCycle(). Here is the call graph for this function: ![]() |
|
creates a new client entry.
Referenced by AcceptTCPConnections(), and ReadUDPMessages(). |
|
called when a new client connects
|
|
called when a client disconnects
|
|
removes all clients marked in the mCloseClients list
Definition at line 414 of file netcontrol.cpp. References mCloseClients, and RemoveClient(). Referenced by EndCycle(). Here is the call graph for this function: ![]() |
|
called once before the simulation is shut down
Reimplemented from oxygen::SimControlNode. Definition at line 205 of file netcontrol.cpp. References zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetName(), mClients, mNetMessage, mSocket, and RemoveClient(). Here is the call graph for this function: ![]() |
|
called when the current simulation cycle ends
Reimplemented from oxygen::SimControlNode. Reimplemented in oxygen::AgentControl, and oxygen::MonitorControl. Definition at line 433 of file netcontrol.cpp. References CloseDeadConnections(). Referenced by oxygen::MonitorControl::EndCycle(), and oxygen::AgentControl::EndCycle(). Here is the call graph for this function: ![]() |
|
returns the local port, on which connections are accepted
Definition at line 54 of file netcontrol.cpp. References mLocalAddr. |
|
returns the type of the socket on which connections are accepted
Definition at line 64 of file netcontrol.cpp. References mSocketType. |
|
creates the managed socket, when the simulation starts
Reimplemented from oxygen::SimControlNode. Definition at line 126 of file netcontrol.cpp. References zeitgeist::Object::GetClass(), zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetName(), mLocalAddr, mNetMessage, mSocket, mSocketType, and ST_TCP. Here is the call graph for this function: ![]() |
|
create a socket according to the given ESocketType
|
|
returns a human readable description of the socket type and port
|
|
reads and stores all available messages
|
|
reads and stores all available TCP messages
Definition at line 534 of file netcontrol.cpp. References zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetName(), mBuffer, mBufferSize, mClients, mCloseClients, and StoreFragment(). Here is the call graph for this function: ![]() |
|
reads and stores all available UDP messages. UDP fragments from unknown sources generate new client entries Definition at line 473 of file netcontrol.cpp. References AddClient(), zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetName(), mBuffer, mBufferSize, mClients, mSocket, and StoreFragment(). Here is the call graph for this function: ![]() |
|
removes a client entry and closes the associated socket.
Referenced by CloseDeadConnections(), and DoneSimulation(). |
|
sends a message to the client with the given address
|
|
sends a message to the given client
Referenced by oxygen::MonitorControl::EndCycle(), and oxygen::AgentControl::EndCycle(). |
|
sets the local port, on which connections are accepted
|
|
sets the type of the socket on which connections are accepted
Definition at line 59 of file netcontrol.cpp. References mSocketType. |
|
called when a new simulation cycle starts, before the simulation is stepped
Reimplemented from oxygen::SimControlNode. Reimplemented in oxygen::AgentControl, and oxygen::MonitorControl. Definition at line 423 of file netcontrol.cpp. References AcceptTCPConnections(). Referenced by oxygen::MonitorControl::StartCycle(), and oxygen::AgentControl::StartCycle(). Here is the call graph for this function: ![]() |
|
copies the message fragment with length
Referenced by ReadTCPMessages(), and ReadUDPMessages(). |
|
the receive buffer
Definition at line 193 of file netcontrol.h. Referenced by NetControl(), ReadTCPMessages(), and ReadUDPMessages(). |
|
list of queued messages
Definition at line 187 of file netcontrol.h. Referenced by oxygen::MonitorControl::StartCycle(), and oxygen::AgentControl::StartCycle(). |
|
the size of the allocated receive buffer
Definition at line 190 of file netcontrol.h. Referenced by NetControl(), ReadTCPMessages(), and ReadUDPMessages(). |
|
the next available unique client id
Definition at line 196 of file netcontrol.h. Referenced by NetControl(). |
|
map of known clients, based on remote address
Definition at line 181 of file netcontrol.h. Referenced by DoneSimulation(), oxygen::MonitorControl::EndCycle(), oxygen::AgentControl::EndCycle(), ReadTCPMessages(), ReadUDPMessages(), and oxygen::AgentControl::StartCycle(). |
|
list of client connections to be closed
Definition at line 184 of file netcontrol.h. Referenced by CloseDeadConnections(), and ReadTCPMessages(). |
|
the local port, on which connections are accepted
Definition at line 172 of file netcontrol.h. Referenced by oxygen::AgentControl::AgentControl(), GetServerPort(), InitSimulation(), oxygen::MonitorControl::MonitorControl(), and NetControl(). |
|
cached reference to the NetMessage child node
Definition at line 169 of file netcontrol.h. Referenced by DoneSimulation(), oxygen::MonitorControl::EndCycle(), oxygen::AgentControl::EndCycle(), InitSimulation(), oxygen::MonitorControl::StartCycle(), and oxygen::AgentControl::StartCycle(). |
|
the socket used to accept connections
Definition at line 178 of file netcontrol.h. Referenced by AcceptTCPConnections(), DoneSimulation(), InitSimulation(), and ReadUDPMessages(). |
|
the type of created socket
Definition at line 175 of file netcontrol.h. Referenced by AcceptTCPConnections(), GetServerType(), InitSimulation(), NetControl(), and SetServerType(). |