Robot Devastation
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
rd::YarpNetworkManager Class Reference

Manages the communications between the user and the Server using YARP. More...

#include <YarpNetworkManager.hpp>

Inheritance diagram for rd::YarpNetworkManager:
rd::NetworkManager rd::MentalMapEventListener rd::test::YarpNetworkManagerNoKeepAlive

Public Member Functions

virtual bool start ()
 Start the network manager. More...
 
virtual bool stop ()
 Stop the network manager.
 
virtual bool isStopped () const
 Returns true if manager is stopped (obviously)
 
virtual bool configure (const std::string &parameter, const Player &value)
 Configures a parameter with a value.
 
virtual bool sendPlayerHit (const Player &player, int damage)
 Communicate to the network that a player has been hit by the user.
 
virtual bool login ()
 Log the user into the network.
 
virtual bool logout ()
 Log the user out of the network.
 
virtual bool keepAlive ()
 Keeps the user connected to the server (requires to be called periodically)
 
- Public Member Functions inherited from rd::NetworkManager
bool addNetworkEventListener (NetworkEventListener *listener)
 Adds a NetworkEventListener to the list of observers to be notified of events.
 
bool removeNetworkEventListeners ()
 Unregisters all the NetworkEventListener stored.
 
bool onTargetHit (const Target &target, const Player &player, const Weapon &weapon)
 Implementation of MentalMapEventListener interface.
 
bool onRespawn (const Player &player)
 Implementation of MentalMapEventListener interface.
 

Static Public Member Functions

static bool RegisterManager ()
 Register this manager in the NetworkManager registry so that can be used. More...
 
- Static Public Member Functions inherited from rd::NetworkManager
static NetworkManagergetNetworkManager ()
 Get a reference to the NetworkManager. More...
 
static NetworkManagergetNetworkManager (const std::string &id)
 Get a reference to the NetworkManager. More...
 
static bool destroyNetworkManager ()
 Deallocate all the registered NetworkManager.
 

Static Public Attributes

static const std::string id = "YARP"
 String that identifies this manager.
 

Protected Member Functions

 YarpNetworkManager ()
 Constructor. More...
 
void onRead (yarp::os::Bottle &b)
 Yarp callback for incoming messages.
 
void run ()
 

Private Member Functions

 YarpNetworkManager (const YarpNetworkManager &)
 
YarpNetworkManageroperator= (const YarpNetworkManager &)
 

Private Attributes

yarp::os::RpcClient rpcClient
 
yarp::os::BufferedPort< yarp::os::Bottle > callbackPort
 
Player player
 Player.
 
bool started
 

Static Private Attributes

static YarpNetworkManageruniqueInstance = NULL
 Reference to this manager (unique instance)
 
static const int KEEPALIVE_RATE_MS = 1000
 Period of the keep alive (called by run() )
 

Additional Inherited Members

- Static Protected Member Functions inherited from rd::NetworkManager
static bool Register (NetworkManager *manager, const std::string &id)
 This function allows subclasses to install their unique instances in the singleton register to be selected later by the user.
 
- Protected Attributes inherited from rd::NetworkManager
std::vector< NetworkEventListener * > listeners
 Observers registered to be notified of network events.
 

Detailed Description

YarpNetworkManager is a singleton text (only one instance of this object can exist, that is is shared by all the users). To use this class, we first get the reference to the YarpNetworkManager with getNetworkManager() and then we access the manager with that reference.

When the program finishes, the YarpNetworkManager can be deallocated using destroyNetworkManager().

Network events are broadcasted to the registered listeners, along with the data relevant to the event triggered (i.e. data that just arrived).

Constructor & Destructor Documentation

◆ YarpNetworkManager()

rd::YarpNetworkManager::YarpNetworkManager ( )
protected

Constructor for this class is non-public since the singleton can only be instantiated once, and the instantiation is done at the RegisterManager() method. Declared protected to allow subclassing.

Member Function Documentation

◆ RegisterManager()

bool rd::YarpNetworkManager::RegisterManager ( )
static

It ensures that only one manager of this type is created (unique instance).

◆ start()

bool rd::YarpNetworkManager::start ( )
virtual

This function is supposed to be called after NetworkManager configuration.

Implements rd::NetworkManager.


The documentation for this class was generated from the following files: