ArnLib
4.0.x
Active Registry Network
|
Remote Procedure Call. More...
#include <ArnRpc.hpp>
Classes | |
struct | Invoke |
Public Types | |
typedef ArnRpcMode | Mode |
Public Slots | |
void | sendText (const QString &txt) |
Send a general text message to the other end of the used pipe More... | |
Signals | |
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... | |
Public Member Functions | |
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... | |
Static Public Member Functions | |
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... | |
Remote Procedure Call.
This is the basic funtionality of RPC. It's recommended to use ArnSapi which uses a higher level model. For now the ArnRpc class is more sparsely documented.
Example usage
Definition at line 156 of file ArnRpc.hpp.
typedef ArnRpcMode ArnRpc::Mode |
Definition at line 162 of file ArnRpc.hpp.
|
explicit |
Definition at line 204 of file ArnRpc.cpp.
ArnRpc::~ArnRpc | ( | ) |
Definition at line 220 of file ArnRpc.cpp.
void ArnRpc::addSenderSignals | ( | QObject * | sender, |
const QString & | prefix | ||
) |
Definition at line 440 of file ArnRpc.cpp.
|
static |
Make batch connection from one senders signals to another receivers slots/signals.
Used when there is a 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.
Example: batchConnect( _commonSapi, ARN_RegExp("^rq_(.+)"), this, "chat\\1");
connects signal: rq_info(QString,QString)
to slot: chatInfo(QString,QString)
[in] | sender | is the sending QObject. |
[in] | rgx | is the regular expression for selecting sender signals. |
[in] | receiver | is the receiving QObject. |
[in] | replace | is the conversion for naming the receiver slots/signals. |
[in] | mode | Used modes: Debug, NoDefaultArgs |
Definition at line 1487 of file ArnRpc.cpp.
|
inline |
Make batch connection from this ArnRpc:s signals to another receivers slots/signals.
Used when there is a 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.
Example: _commonSapi.batchConnect( ARN_RegExp("^rq_(.+)"), this, "chat\\1");
connects signal: rq_info(QString,QString)
to slot: chatInfo(QString,QString)
[in] | rgx | is the regular expression for selecting sender signals. |
[in] | receiver | is the receiving QObject. |
[in] | replace | is the conversion for naming the receiver slots/signals. |
[in] | mode |
Definition at line 348 of file ArnRpc.hpp.
|
inline |
Make batch connection from one senders signals to this ArnRpc:s slots/signals.
Used when there is a 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.
Example: _commonSapi.batchConnect( _commonSapi, ARN_RegExp("^chat(.+)"), "rq_\\1");
connects signal: chatinfo(QString,QString)
to slot: rq_Info(QString,QString)
[in] | sender | is the sending QObject. |
[in] | rgx | is the regular expression for selecting sender signals. |
[in] | replace | is the conversion for naming the receiver slots/signals. |
[in] | mode |
Definition at line 369 of file ArnRpc.hpp.
|
signal |
Signal emitted when receiver method missing.
This signal is only emitted if Mode::useDefaultCall is active. Error notification is then canceled.
[in] | data | is the received call message in XString format. |
int ArnRpc::getHeartBeatCheck | ( | ) | const |
Get max time period for receiving heart beat message.
Time zero is turned off checking.
Definition at line 424 of file ArnRpc.cpp.
int ArnRpc::getHeartBeatSend | ( | ) | const |
Get period time for sending heart beat message.
Time zero is turned off sending.
Definition at line 405 of file ArnRpc.cpp.
|
signal |
Signal emitted when Heart beat changes state.
Heart beat messages are detected and expected within a check time. If this is satisfied, the state of heart beat is ok.
[in] | isOk | is the Heart beat state, false = Not received. |
|
signal |
Signal emitted when Heart beat message is received.
bool ArnRpc::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.
This is the low level way to call a remote procedure. It can freely call anything without declaring it. For high level calls use ArnSapi.
This function works similar to QMetaObject::invokeMethod(). The called name is prefixed before the final call is made. Using the label in MQ_ARG() makes dubugging easier, as the parameter is named.
Example: rpc->invoke("myfunc", MQ_ARG( QString, mypar, "Test XYZ"));
[in] | funcName | is the name of the called procedure. |
[in] | val0 | first arg. |
[in] | val1 | |
[in] | val2 | |
[in] | val3 | |
[in] | val4 | |
[in] | val5 | |
[in] | val6 | |
[in] | val7 |
Definition at line 494 of file ArnRpc.cpp.
bool ArnRpc::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.
This is the low level way to call a remote procedure. It can freely call anything without declaring it. For high level calls use ArnSapi.
This function works similar to QMetaObject::invokeMethod(). The called name is prefixed before the final call is made. Using the label in MQ_ARG() makes dubugging easier, as the parameter is named.
Example: rpc->invoke("myfunc", ArnRpc::Invoke::NoQueue, MQ_ARG( QString, mypar, "Test XYZ"));
[in] | funcName | is the name of the called procedure. |
[in] | invokeFlags | is flags for controlling the invoke |
[in] | val0 | first arg. |
[in] | val1 | |
[in] | val2 | |
[in] | val3 | |
[in] | val4 | |
[in] | val5 | |
[in] | val6 | |
[in] | val7 |
Definition at line 533 of file ArnRpc.cpp.
bool ArnRpc::isHeartBeatOk | ( | ) | const |
Get the state of heart beat.
false | if not getting heart beat in time |
Definition at line 432 of file ArnRpc.cpp.
QString ArnRpc::methodPrefix | ( | ) | const |
Definition at line 346 of file ArnRpc.cpp.
ArnRpc::Mode ArnRpc::mode | ( | ) | const |
bool ArnRpc::open | ( | const QString & | pipePath | ) |
Definition at line 236 of file ArnRpc.cpp.
|
signal |
Signal emitted when checked sequence order is wrong.
ArnPipe * ArnRpc::pipe | ( | ) | const |
|
signal |
Signal emitted when the used pipe is closed.
The pipe closes when its Arn Data Object is destroyed, i.e. the session is considered ended.
QString ArnRpc::pipePath | ( | ) | const |
QObject * ArnRpc::receiver | ( | ) | const |
Definition at line 329 of file ArnRpc.cpp.
ArnRpc * ArnRpc::rpcSender | ( | ) |
Definition at line 473 of file ArnRpc.cpp.
|
static |
Definition at line 483 of file ArnRpc.cpp.
|
slot |
Send a general text message to the other end of the used pipe
Is used by ArnRpc to give errors and help messages, mostly for debugging.
[in] | txt | is the text to be sent |
Definition at line 1466 of file ArnRpc.cpp.
void ArnRpc::setHeartBeatCheck | ( | int | time | ) |
Set max time period for receiving heart beat message.
Setting time to zero will turn off checking.
[in] | time | is the time period in seconds |
Definition at line 413 of file ArnRpc.cpp.
void ArnRpc::setHeartBeatSend | ( | int | time | ) |
Set period time for sending heart beat message.
Setting time to zero will turn off sending.
[in] | time | is the time period in seconds |
Definition at line 394 of file ArnRpc.cpp.
void ArnRpc::setIncludeSender | ( | bool | v | ) |
Add sender as argument when calling a rpc method.
Definition at line 370 of file ArnRpc.cpp.
void ArnRpc::setMethodPrefix | ( | const QString & | prefix | ) |
Definition at line 337 of file ArnRpc.cpp.
void ArnRpc::setMode | ( | Mode | mode | ) |
Definition at line 378 of file ArnRpc.cpp.
void ArnRpc::setPipe | ( | ArnPipe * | pipe | ) |
Set pipe for this Rpc.
The Rpc will take ownership of the pip.
[in] | pipe |
Definition at line 273 of file ArnRpc.cpp.
bool ArnRpc::setReceiver | ( | QObject * | receiver, |
bool | useTrackRpcSender = true |
||
) |
Definition at line 300 of file ArnRpc.cpp.
|
signal |
Signal emitted when a general text message is received.
The text message is received from the other end of the used pipe.
[in] | text | is the received text |