fwRPC
|
Functions | |
bool | fwRPC_msgClient_isRunning (anytype ctx) |
int | fwRPC_msgClient_initialize (anytype &ctx, bool local, string typeTag, string &name, mapping msgDelegates) |
int | fwRPC_msgClient_stop (anytype ctx) |
synchronized int | fwRPC_msgClient_send (anytype ctx, string type, string sysName, string name, mixed payload="") |
synchronized int | fwRPC_msgClient_sendRequest (anytype ctx, string type, mixed payload="") |
string | fwRPC_msgClient_getName (anytype ctx) |
private void | _fwRPC_msgClient_monitor (anytype ctx, string rbMbxDp) |
private void | _fwRPC_msgClient_link (anytype ctx, string rbMbxDp) |
private void | _fwRPC_msgClient_unlink (anytype ctx, string rbMbxDp) |
synchronized private void | _fwRPC_msgClient_msgInCB (dyn_string userData, string dpe, uint writeidx) |
synchronized private void | _fwRPC_msgClient_rbDrainCB (string ctx, string readidx) |
Variables | |
global const int | fwRPC_MSGCLIENT_E_SUCCESS = 0 |
global const int | fwRPC_MSGCLIENT_E_ERROR = -1 |
global const int | fwRPC_MSGCLIENT_E_NOT_RUNNING = -2 |
const int | fwRPC_MSGCLIENT_TYPE_CLIENT = 0 |
const int | fwRPC_MSGCLIENT_TYPE_SERVER = 1 |
const int | fwRPC_MSGCLIENT_TYPE_WORKER = 2 |
const int | fwRPC_MSGCLIENT_MONITOR_INTERVAL_SEC = 2 |
private global mapping | g_fwRPC_msgClient_isRunning |
private global mapping | g_fwRPC_msgClient_name |
private global mapping | g_fwRPC_msgClient_msgDelegates |
private global mapping | g_fwRPC_msgClient_msgBuffer |
private global mapping | g_fwRPC_msgClient_monitor_tid |
This file contains functionality required for client-side communication within the fwRPC communication model.
Inbound messages are processed at most once.
Outbound messages are buffered internally if the target ringbuffer is full until the ringbuffer is read from, after which the client will automatically attempt to write again from the buffer.
string fwRPC_msgClient_getName | ( | anytype | ctx | ) |
Retrieve the name of the client instance.
nothing |
int fwRPC_msgClient_initialize | ( | anytype & | ctx, |
bool | local, | ||
string | typeTag, | ||
string & | name, | ||
mapping | msgDelegates | ||
) |
Initialise and run a fwRPC message client with a given name. If no name is specified, one is generated and returned as an output param.
Accepts a mapping of fwRPC_DIST_TAG_* to delegate function names. Delegate functions must have the following signature:
void func(string project, string name, anytype msg);
Where project is the origin project, name is the origin name msg is the unserialized message payload
typeTag can be any of the following: fwRPC_DIST_TAG_CLIENT fwRPC_DIST_TAG_CORE fwRPC_DIST_TAG_WORKER
The msgDelegates mapping must keep to the following structure: key = message type (fwRPC_DISTMSG_TYPE_*) value = function name of STRING
local | (IN, bool) whether or not to initialize in local mode |
typeTag | (IN, string) client type (fwRPC_DIST_TAG_* |
msgDelegates | (IN, string) mapping of fwRPC_DISTMSG_TYPE_* to function name |
name | (IN|OUT, mapping) client name |
if | the parameters are invalid |
bool fwRPC_msgClient_isRunning | ( | anytype | ctx | ) |
Return whether or not the client module is running
synchronized int fwRPC_msgClient_send | ( | anytype | ctx, |
string | type, | ||
string | sysName, | ||
string | name, | ||
mixed | payload = "" |
||
) |
Send a message to a given callee with specific payload.
Messages are processed at the receiver at most once.
The payload is automatically serialized.
type | (IN, string) message type |
sysName | (IN, string) target system name |
name | (IN, string) target name |
payload | (IN, mixed) message payload (non serialized) |
nothing |
synchronized int fwRPC_msgClient_sendRequest | ( | anytype | ctx, |
string | type, | ||
mixed | payload = "" |
||
) |
Send a request with a given payload. The destination is determined by the broker and routed to the correct callee.
Messages are processed at the receiver at most once.
The payload is automatically serialized.
This function behaves the same as fwRPC_msgClient_msg_send with the destination set to broker defaults.
type | (IN, string) message type |
paylad | (IN, mixed) message payload (non serialized) |
nothing |
int fwRPC_msgClient_stop | ( | anytype | ctx | ) |
Stop the running client module. Disconnects from ringbuffer messagebox updates.
nothing |
global const int fwRPC_MSGCLIENT_E_SUCCESS = 0 |
Return codes
@ {
const int fwRPC_MSGCLIENT_TYPE_CLIENT = 0 |
Client types
: msgClient should not know about RPC stuff
@ {
private global mapping g_fwRPC_msgClient_isRunning |
Whether or not the client is running Structure: key = client context handle value = if client with given ctx is running
private global mapping g_fwRPC_msgClient_monitor_tid |
Current tid of the dp connection monitor Structure: key = client context handle value = monitor thread id of client with given ctx
private global mapping g_fwRPC_msgClient_msgBuffer |
Outbound message buffer. If the outbound ringbuffer is full, messages are enqueued here.
Structure: key = client context handle value = DYN_STRING:
private global mapping g_fwRPC_msgClient_msgDelegates |
A mapping of message delegate functions. Structure: key = client context handle value = MAPPING: key = fwRPC_DISTMSG_TYPE_* value = STRING: function name
private global mapping g_fwRPC_msgClient_name |
The client name Structure: key = client context handle value = client name with given ctx