ArnLib
4.0.x
Active Registry Network
|
Service API. More...
#include <ArnSapi.hpp>
Public Member Functions | |
ArnSapi (QObject *parent=arnNullptr) | |
bool | open (const QString &pipePath=QString(), Mode mode=Mode(), const char *providerPrefix=arnNullptr, const char *requesterPrefix=arnNullptr) |
Open a new Service API. More... | |
void | batchConnectTo (const QObject *receiver, const QString &prefix=QString(), Mode mode=Mode()) |
Make batch connection from this ArnSapi:s signals to another receivers slots/signals. More... | |
void | batchConnectFrom (const QObject *sender, const QString &prefix=QString(), Mode mode=Mode()) |
Make batch connection from one senders signals to this ArnSapi:s signals. More... | |
QString | defaultPath () const |
Get default path for the pipe to be used. More... | |
![]() | |
ArnRpc (QObject *parent=arnNullptr) | |
~ArnRpc () | |
QString | pipePath () const |
Get the path for the used pipe More... | |
bool | open (const QString &pipePath) |
void | setPipe (ArnPipe *pipe) |
Set pipe for this Rpc. More... | |
ArnPipe * | pipe () const |
Get the used pipe More... | |
bool | setReceiver (QObject *receiver, bool useTrackRpcSender=true) |
QObject * | receiver () const |
void | setMethodPrefix (const QString &prefix) |
QString | methodPrefix () const |
void | setIncludeSender (bool v) |
Add sender as argument when calling a rpc method. More... | |
void | setMode (Mode mode) |
Mode | mode () const |
Get the mode. More... | |
void | setHeartBeatSend (int time) |
Set period time for sending heart beat message. More... | |
int | getHeartBeatSend () const |
Get period time for sending heart beat message. More... | |
void | setHeartBeatCheck (int time) |
Set max time period for receiving heart beat message. More... | |
int | getHeartBeatCheck () const |
Get max time period for receiving heart beat message. More... | |
bool | isHeartBeatOk () const |
Get the state of heart beat. More... | |
void | addSenderSignals (QObject *sender, const QString &prefix) |
bool | invoke (const QString &funcName, MQGenericArgument val0=MQGenericArgument(0), MQGenericArgument val1=MQGenericArgument(), MQGenericArgument val2=MQGenericArgument(), MQGenericArgument val3=MQGenericArgument(), MQGenericArgument val4=MQGenericArgument(), MQGenericArgument val5=MQGenericArgument(), MQGenericArgument val6=MQGenericArgument(), MQGenericArgument val7=MQGenericArgument()) |
Calls a named remote procedure. More... | |
bool | invoke (const QString &funcName, Invoke invokeFlags, MQGenericArgument val0=MQGenericArgument(0), MQGenericArgument val1=MQGenericArgument(), MQGenericArgument val2=MQGenericArgument(), MQGenericArgument val3=MQGenericArgument(), MQGenericArgument val4=MQGenericArgument(), MQGenericArgument val5=MQGenericArgument(), MQGenericArgument val6=MQGenericArgument(), MQGenericArgument val7=MQGenericArgument()) |
Calls a named remote procedure using invoke flags. More... | |
ArnRpc * | rpcSender () |
void | batchConnect (const ARN_RegExp &rgx, const QObject *receiver, const QString &replace, Mode mode=Mode()) |
Make batch connection from this ArnRpc:s signals to another receivers slots/signals. More... | |
void | batchConnect (const QObject *sender, const ARN_RegExp &rgx, const QString &replace, Mode mode=Mode()) |
Make batch connection from one senders signals to this ArnRpc:s slots/signals. More... | |
Protected Member Functions | |
ArnSapi (const QString &defaultPath, QObject *parent=arnNullptr) | |
void | setDefaultPath (const QString &defaultPath) |
Set default path for the pipe to be used. More... | |
Additional Inherited Members | |
![]() | |
typedef ArnRpcMode | Mode |
![]() | |
void | sendText (const QString &txt) |
Send a general text message to the other end of the used pipe More... | |
![]() | |
void | pipeClosed () |
Signal emitted when the used pipe is closed. More... | |
void | textReceived (const QString &text) |
Signal emitted when a general text message is received. More... | |
void | defaultCall (const QByteArray &data) |
Signal emitted when receiver method missing. More... | |
void | outOfSequence () |
Signal emitted when checked sequence order is wrong. More... | |
void | heartBeatChanged (bool isOk) |
Signal emitted when Heart beat changes state. More... | |
void | heartBeatReceived () |
Signal emitted when Heart beat message is received. More... | |
![]() | |
static ArnRpc * | rpcSender (QObject *receiver) |
static void | batchConnect (const QObject *sender, const ARN_RegExp &rgx, const QObject *receiver, const QString &replace, Mode mode=Mode()) |
Make batch connection from one senders signals to another receivers slots/signals. More... | |
Service API.
This class serves as a base class for Service Application Programming Interface. It should be derived to a custom class that descibe a specific SAPI.
By default all provider services are prefixed by "pv_" and all requester "services" are prefixed by "rq_". This standard can be changed.
The meta prefix no_queue is used to limit the filling of sendqueue with recuring RPC calls during some kind of client disconnection. Matched function name in sendqueue is overwritten by the last call. This functionality uses pipe anti congest. This is internally used for heart beat, but other typical usages can be ping, request update etc.
Example usage
Definition at line 115 of file ArnSapi.hpp.
|
explicit |
Definition at line 47 of file ArnSapi.cpp.
|
protected |
Definition at line 53 of file ArnSapi.cpp.
void ArnSapi::batchConnectFrom | ( | const QObject * | sender, |
const QString & | prefix = QString() , |
||
ArnRpc::Mode | mode = Mode() |
||
) |
Make batch connection from one senders signals to this ArnSapi:s signals.
Used when there is a specific pattern in the naming of the signals. It's assumed that naming for signals are unique regardless of its case i.e. using both test() and tesT() are not allowed.
Example: Requester doing _commonSapi.batchConnectFrom( mySender, "sapi");
Can connect signal: sapiNewMsg(QString,QString)
to signal: pv_newMsg(QString,QString)
[in] | sender | is the sending QObject. |
[in] | prefix | is the prefix for sending signal names. |
[in] | mode |
Definition at line 107 of file ArnSapi.cpp.
void ArnSapi::batchConnectTo | ( | const QObject * | receiver, |
const QString & | prefix = QString() , |
||
ArnRpc::Mode | mode = Mode() |
||
) |
Make batch connection from this ArnSapi:s signals to another receivers slots/signals.
Used when there is a specific pattern in the naming of the signals and slots. It's assumed that naming for slots are unique regardless of its case i.e. using both test() and tesT() are not allowed.
When Mode::UseDefaultCall is active, then also the defaultCall() signal is connected to the receiver. Method name will be using the prefix and end with "Default". E.g. prefix is "sapi" will give method name "sapiDefault".
Example: Provider doing _commonSapi.batchConnectTo( myReceiver, "sapi");
Can connect signal: pv_newMsg(QString,QString)
to slot: sapiNewMsg(QString,QString)
[in] | receiver | is the receiving QObject. |
[in] | prefix | is the prefix for receiving slot/signal names. |
[in] | mode |
Definition at line 89 of file ArnSapi.cpp.
QString ArnSapi::defaultPath | ( | ) | const |
Get default path for the pipe to be used.
Definition at line 118 of file ArnSapi.cpp.
bool ArnSapi::open | ( | const QString & | pipePath = QString() , |
Mode | mode = Mode() , |
||
const char * | providerPrefix = arnNullptr , |
||
const char * | requesterPrefix = arnNullptr |
||
) |
Open a new Service API.
The opened Sapi can be either the provider side or the requester side, which is indicated by mode. The provider marker "!" in the pipePath will automatically be set/removed in accordance to the mode.
Typically the provider is only using mode Provider. The requester can use default mode for a static pipe and typically use the UuidAutoDestroy mode for dynamic session pipes.
[in] | pipePath | is the path used for Sapi. Empty string gives default. |
[in] | mode | |
[in] | providerPrefix | to set a custom prefix for provider signals. |
[in] | requesterPrefix | to set a custom prefix for requester signals. |
false | if error |
Definition at line 66 of file ArnSapi.cpp.
|
protected |
Set default path for the pipe to be used.
A provider path will always be converted to a non provider path.
[in] | defaultPath |
Definition at line 126 of file ArnSapi.cpp.