fwRPC
|
Functions | |
bool | fwRPC_msgBroker_isRunning () |
void | fwRPC_msgBroker_initialize () |
void | fwRPC_msgBroker_accept (string msgType, string delegate, string acceptedSource,...) |
int | fwRPC_msgBroker_listen (bool localListen, string newMbxCB="") |
int | fwRPC_msgBroker_stop () |
synchronized int | fwRPC_msgBroker_writeMessage (string targetProject, string targetName, string type, mixed payload="", string sourceProject="", string sourceName="") |
int | fwRPC_msgBroker_getHandleCallee (anytype hdl, string &project, string &name) |
int | fwRPC_msgBroker_getHandleCaller (anytype hdl, string &project, string &name) |
int | fwRPC_msgBroker_registerHandle (anytype hdl, string senderProject, string senderName, string targetProject="", string targetName="") synchronized(g_fwRPC_msgBroker_hdl_registry) |
int | fwRPC_msgBroker_setHandleCallee (anytype hdl, string project, string name) synchronized(g_fwRPC_msgBroker_hdl_registry) |
int | fwRPC_msgBroker_unregisterHandle (anytype hdl) synchronized(g_fwRPC_msgBroker_hdl_registry) |
void | fwRPC_msgBroker_getHandlesCalledBy (string project, string name, dyn_string &hdls) synchronized(g_fwRPC_msgBroker_hdl_registry) |
synchronized private void | _fwRPC_msgBroker_newSystemCB (string newMbxCB, string dpe, time lastUpdateTime) |
private void | _fwRPC_msgBroker_getProjectInfoFromDpe (string dpe, string &dp, string &systemName, string &name) |
synchronized private void | _fwRPC_msgBroker_newMbxCB (string cb, dyn_dyn_anytype results) |
synchronized private void | _fwRPC_msgBroker_msgInCB (anytype _, dyn_dyn_anytype results) |
synchronized private void | _fwRPC_msgBroker_rbDrainCB (anytype _, dyn_dyn_string results) |
private void | _fwRPC_msgBroker_processOverflowBuffer (string dp) |
private string | _fwRPC_msgBroker_buildRbPointerDpe (bool read) |
private string | _fwRPC_msgBroker_buildRbMbxQuery (bool local, string rb_dpe, string remote="") |
private int | _fwRPC_msgBroker_listenSystem (bool localListen, string newMbxCB="", string systemName="") |
private void | _fwRPC_msgBroker_assertRunning (bool running) |
Variables | |
global const int | fwRPC_MSGBROKER_E_SUCCESS = 0 |
global const int | fwRPC_MSGBROKER_E_ERROR = -1 |
private global mapping | g_fwRPC_msgBroker_msgDelegates |
private global mapping | g_fwRPC_msgBroker_hdl_registry |
private global dyn_uint | g_fwRPC_msgBroker_connectedSystems |
private global mapping | g_fwRPC_msgBroker_msgBuffers |
private global string | g_fwRPC_msgBroker_newMbxCB |
private global bool | g_fwRPC_msgBroker_localListen |
private global bool | g_fwRPC_msgBroker_isRunning = false |
private global const int | HDL_REG_SRC = 1 |
private global const int | HDL_REG_TARGET = 2 |
private global const int | MSG_DELEGATE_FUNC = 1 |
private global const int | MSG_DELEGATE_ACCEPTED = 2 |
This library contains the RPC broker module functionality. Part of the server-side RPC library.
The broker module acts as a RB_MBX listener and is responsible for delegating messages to registered handler functions.
void fwRPC_msgBroker_accept | ( | string | msgType, |
string | delegate, | ||
string | acceptedSource, | ||
... | |||
) |
Register a delegate function for a specific message type, and accept such requests only from specific source types.
Requests inbound from unaccepted source types will not be sent to the delegate.
Acceptable source types include fwRPC_DIST_TAG_CLIENT fwRPC_DIST_TAG_WORKER fwRPC_DIST_TAG_CORE
Accepts a mapping of message type to delegate function names with the following signature:
void func( string project, string name, anytype buffer, string target_project, string target_name );
Where project is the requesting project name is the requesting name buffer is the deserialized message buffer target_project is the intended target project requested by the client target_name is the intended target name requested by the client
target_project and target_name are optional parameters.
msgType | (IN, string) message type |
delegate | (IN, string) delegate function |
acceptedSource | (IN, string) accepted source type |
... | (IN, string) <accepted source="" types>=""> |
if | the broker module is not running if the delegate was already registered |
int fwRPC_msgBroker_getHandleCallee | ( | anytype | hdl, |
string & | project, | ||
string & | name | ||
) |
Retrieve the callee of a registered handle.
hdl | (IN, anytype) handle to check for |
project | (OUT, string) handle callee project |
name | (OUT, string) handle callee name |
if | the broker module is not running |
int fwRPC_msgBroker_getHandleCaller | ( | anytype | hdl, |
string & | project, | ||
string & | name | ||
) |
Retrieve the caller of a previously registered handle.
hdl | (IN, anytype) handle to check for |
project | (OUT, string) handle caller project |
name | (OUT, string) handle caller name |
if | the broker module is not running |
void fwRPC_msgBroker_getHandlesCalledBy | ( | string | project, |
string | name, | ||
dyn_string & | hdls | ||
) |
Retrieve a list of all handles registered with a given caller.
project | (IN, string) caller project |
name | (IN, string) caller name |
hdls | (OUT, dyn_string) list of handles |
if | the broker module is not running |
void fwRPC_msgBroker_initialize | ( | ) |
Initialize the broker module. Resets local state.
bool fwRPC_msgBroker_isRunning | ( | ) |
Check if the broker is currently running or not.
nothing |
int fwRPC_msgBroker_listen | ( | bool | localListen, |
string | newMbxCB = "" |
||
) |
Initialise the message broker and listen for outgoing messages from clients. The broker will listen for local or remote RB_MBX events as specified by the localListen parameter.
The message broker itself does not create a RB_MBX DP.
Note that _stop() and _listen() should both be called from the same context, i.e, within a monitor in order for dpDisconnect to succeed.
localListen | (IN, bool) whether to listen for local or remote RB_MBX events |
newMbxCB | (IN, string) function to call when a new comm endpoint is detected |
if | the parameters are invalid if the broker is already running |
int fwRPC_msgBroker_registerHandle | ( | anytype | hdl, |
string | senderProject, | ||
string | senderName, | ||
string | targetProject = "" , |
||
string | targetName = "" |
||
) |
Register a caller and callee with a specific handle. If the handle is already registered, no insertion is performed.
Once registered, the callee of the handle can be specified using the _setHandleCallee() function.
hdl | (IN, anytype) handle to register |
senderProject | (IN, string) caller project |
senderName | (IN, string) caller name |
targetProject | (IN, string) callee project |
targetName | (IN, string) callee name |
if | the broker module is not running |
int fwRPC_msgBroker_setHandleCallee | ( | anytype | hdl, |
string | project, | ||
string | name | ||
) |
Set the target (callee) of a previously registered handle.
Handles must be registered beforehand using the _registerHandle() function.
hdl | (IN, anytype) handle to update |
project | (IN, string) callee project |
name | (IN, string) callee name |
if | the broker module is not running |
int fwRPC_msgBroker_stop | ( | ) |
Stop the currently running message broker.
Note that _stop() and _listen() should both be called from the same context, i.e, within a monitor in order for dpDisconnect to succeed.
if | the broker is not running |
int fwRPC_msgBroker_unregisterHandle | ( | anytype | hdl | ) |
Remove a handle from the registry.
hdl | (IN, anytype) handle to remove |
if | the broker module is not running |
synchronized int fwRPC_msgBroker_writeMessage | ( | string | targetProject, |
string | targetName, | ||
string | type, | ||
mixed | payload = "" , |
||
string | sourceProject = "" , |
||
string | sourceName = "" |
||
) |
Write a message directly to the destination RB_MBX input.
targetProject | (IN, string) destination project |
targetName | (IN, string) destination name |
type | (IN, string) message type |
payload | (IN, mixed) message contents |
if | the broker module is not running |
global const int fwRPC_MSGBROKER_E_SUCCESS = 0 |
Begin error codes
private global dyn_uint g_fwRPC_msgBroker_connectedSystems |
List of connected systems. Values are system numbers.
private global mapping g_fwRPC_msgBroker_hdl_registry |
Mapping of registered handles, including source and destination info. key = message handle value = dyn_mixed of dyn_string pairs of the following structure: fwRPC_DIST_NODE_PROJECT fwRPC_DIST_NODE_NAME HDL_REG_TARGET
private global bool g_fwRPC_msgBroker_isRunning = false |
Whether the broker is running or not
private global bool g_fwRPC_msgBroker_localListen |
Whether the broker is listening for local or remote endpoints
private global mapping g_fwRPC_msgBroker_msgBuffers |
Mapping of message buffers. Messages are buffered here if the destination ring buffer is full. key = ringbuffer dp value = dyn_string messages
private global mapping g_fwRPC_msgBroker_msgDelegates |
Mapping of registered message delegates. key = message type value = DYN_MIXED: [MSG_DELEGATE_FUNC] [x]: client type
private global string g_fwRPC_msgBroker_newMbxCB |
Function to call when a new communication endpoint is detected
private global const int HDL_REG_SRC = 1 |
End error codes
private global const int HDL_REG_TARGET = 2 |
End error codes
private global const int MSG_DELEGATE_ACCEPTED = 2 |
End error codes
private global const int MSG_DELEGATE_FUNC = 1 |
End error codes