Chapter 2.1 : Creating the Client/Server
Clients and severs are both base on a PAbstractControlManager which deals with the different backends and allows to manage different connections with all the other clients or servers you wan to use.A client can be defined with :
1 2 3 4 5 6 7 8 9 |
#include "phoenix_control.h" //Let's define our manager typedef PAbstractControlManager<std::string, PEmptyControlBackend, PMockControlBackend> ConnectorManager; void mainManagerStart(){ ConnectorManager manager; manager.addClientConnector("Alice", "localhost", phoenix_emptyControlParam("empty_log", PLog::DEBUG)); } |
Here, all Connector are defined by a name, Alice in this case. This corresponds to the first tempalte parameters of the PAbstractControlManager. If you prefer, You can use an int or any type supported by a std::map .
The second template parameters is the production backend to be used, in our case PEmptyControlBackend which does nothing. The third template parameters is the mock backend, in our case, the default mock PMockControlBackend, which can mock any other client / server behaviour.
Creating a server is really close :
1 2 3 4 5 6 7 8 9 |
#include "phoenix_control.h" //Let's define our manager typedef PAbstractControlManager<std::string, PEmptyControlBackend, PMockControlBackend> ConnectorManager; void mainManagerStart(){ ConnectorManager manager; manager.addServerConnector("Alice", "localhost", phoenix_emptyControlParam("empty_log", PLog::DEBUG)); } |
The mock backend PMockControlBackend does not make any difference between client and server due to its mock nature.