|
PdCom
5.0
Process data communication client
|
Base class for PdCom protocol handler. More...
#include <Process.h>
Classes | |
| struct | protocol_error |
Public Member Functions | |
| Process () | |
| Constructor. | |
| Process (Process &&)=delete | |
| Process & | operator= (Process &&)=delete |
| virtual | ~Process () |
| Destructor. More... | |
| std::string | name () const |
| Remote process name string. | |
| std::string | version () const |
| Remote process version string. | |
| void | reset () |
| Reset communications and clean up internal buffers. | |
| virtual std::string | applicationName () const |
| Name of application user application. More... | |
| virtual std::string | hostname () const |
| Host name of remote server. More... | |
| void | asyncData () |
| Library entry point for new data. More... | |
| void | callPendingCallbacks () |
| Call delayed callbacks. More... | |
| bool | list (const std::string &path="") |
| List a directory path. More... | |
| bool | find (const std::string &path) |
| Find a variable with a corresponding path. More... | |
| virtual void | findReply (const Variable &variable) |
| Reply to find() More... | |
| void | ping () |
| Ping server. | |
| void | setAuthManager (Sasl *) |
| Register a SASL handler. More... | |
| void | broadcast (const std::string &message, const std::string &attr="text") |
| Send a broadcast message to the server and other clients. More... | |
Friends | |
| class | impl::Process |
| class | SecureProcess |
Base class for PdCom protocol handler.
This is the base class to interact with real time process server. The PdCom protocol ist implemented using this class.
For socket input and output, the library completely relies on a derived class where read(), write(), flush() and connected() methods are reimplemented.
When data is available for reading, call asyncData() which in turn calls the reimplemented read() method.
When the protocol is initialized, the reimplemented connected() method is called. Other than startTLS(), login(), none of the command methods listed below may be called prior to connected().
After connected(), the following commands can be issued:
startTLS() and login() may only be called prior to connected() when the library has called startTLSReply() or loginReply() previously.
All these commands are non-blocking asynchronous calls and either return the result immediately with the corresponding reply methods or issue a command to the server using excessive (!) calls to write(). Data should be written to a buffer to optimize network communication. To flush the buffer to wire, flush() is issued by the library when required.
The server may query presence of the user by issuing an alive() call. Using this call, certain actions could be undertaken by the server if the user is not active any more.
|
virtual |
Destructor.
The destructor cleans up all internally allocated structures
|
inlinevirtual |
Name of application user application.
The application name is transferred to the server to be able to identify the clients more easily.
| void PdCom::Process::asyncData | ( | ) |
Library entry point for new data.
Calling this method tells the library that new data has arrived from the server and is waiting to be processed.
The library prepares an input buffer and then calls the reimplemented read() virtual method to read incoming data.
This method can throw many exceptions, especially protocol_error and all exceptions which are thrown in the callbacks.
| void PdCom::Process::broadcast | ( | const std::string & | message, |
| const std::string & | attr = "text" |
||
| ) |
Send a broadcast message to the server and other clients.
| message | Broadcast message. |
| attr | Xml tag name, can be text or action. |
| void PdCom::Process::callPendingCallbacks | ( | ) |
Call delayed callbacks.
This method is used to call queued callbacks, for example Subscriber::stateChanged() after a Subscription has been created. It is also called twice by asyncData(), so usually you don't have to bother with it.
| bool PdCom::Process::find | ( | const std::string & | path | ) |
Find a variable with a corresponding path.
If the path search is known (be it successful or unsuccessful), the variable is returned in the call to the reimplemented virtual findReply() method immediately and the method returns true;
If unsuccessful, the command is sent to the server to and the call returns immediately with false. Later on during asyncData(), findReply() is called when the server's reply is processed.
| path | path of variable to find |
|
virtual |
Reply to find()
This virtual method is called within the context of asyncData() when the server's reply to a variable discovery is processed.
findReply()ies are called in strict order of find()
| variable | Variable, empty if variable was not found. |
|
inlinevirtual |
Host name of remote server.
Reimplement this method to return the remote server host name this library connects to. This is especially important in multi-hosted TLS environments, where multiple hosts resolv to the same IP address. TLS needs to know the original server host name.
| bool PdCom::Process::list | ( | const std::string & | path = "" | ) |
List a directory path.
A process command to return all variables and directories within a directory path. The path parameter has typical unix character, with forward slashes '/' separating directories.
listReply() must be reimplemented to receive the reply to this call.
If the directory is cached (for instance a previous call to a similar path, or an entire server listing has been performed), listReply() is called within the context of this call and no server query is performed.
If uncached, the library sends a server query and returns immediately. Later on during asyncData(), the virtual method listReply(), is called when the server's reply is processed.
As a special case, an empty string (std::string()) for path will let the server list all its variables in one go. This possibility must be used with caution, as it can cause heavy network traffic.
| path | directory path |
| void PdCom::Process::setAuthManager | ( | Sasl * | ) |
Register a SASL handler.
A previous registered handler will be unregistered. Note that the registered handler has to outlive the process. Passing a nullptr will unregister the handler.
1.8.14