Remote Procedure Call (RPC) over Websockets (uses MbedJSONValue)
Dependents: RPC_mbed_client RPC_Wifly_HelloWorld RPC_Ethernet_HelloWorld
MbedJSONRpc Class Reference
MbedJSONRpc class. More...
#include <MbedJSONRpc.h>
Public Member Functions | |
MbedJSONRpc (Websocket *webs) | |
Constructor. | |
template<typename T > | |
RPC_TYPE | registerMethod (const char *public_name, T *obj_ptr, void(T::*fn)(MbedJSONValue &val, MbedJSONValue &res)) |
Register a method of an object. | |
RPC_TYPE | registerMethod (const char *public_name, void(*fn)(MbedJSONValue &val, MbedJSONValue &res)) |
Register a procedure. | |
RPC_TYPE | call (char *fn, char *dest, MbedJSONValue &val, MbedJSONValue &resp) |
Call a method or procedure on a client. | |
void | work () |
Listen for CALL requests. | |
void | checkMethods (char *dest) |
Print by the usb serial port all methods or procedure available on "dest" client. |
Detailed Description
MbedJSONRpc class.
Definition at line 101 of file MbedJSONRpc.h.
Constructor & Destructor Documentation
MbedJSONRpc | ( | Websocket * | webs ) |
Constructor.
- Parameters:
-
id Name of the client on the network ws All communication between clients will be established over this websocket
Definition at line 110 of file MbedJSONRpc.h.
Member Function Documentation
RPC_TYPE call | ( | char * | fn, |
char * | dest, | ||
MbedJSONValue & | val, | ||
MbedJSONValue & | resp | ||
) |
Call a method or procedure on a client.
- Parameters:
-
fn name of the method or procedure to be called dest name of the client where will be executed the method or procedure val Input parameters of the method or procedure "fn" resp Once the method or procedure executed, the result will be stored in the "resp" variable.
- Returns:
- If CALL_OK, the method has been executed and you can access the result with the "resp" variable. If CLIENT_NOT_CONNECTED, means that the client hasn't answered within 3s. If SERVER_NOT_CONNECTED, means that the server hasn't answered within 5s. Refer to the RPC_TYPE description
Definition at line 3 of file MbedJSONRpc.cpp.
void checkMethods | ( | char * | dest ) |
Print by the usb serial port all methods or procedure available on "dest" client.
Definition at line 57 of file MbedJSONRpc.cpp.
RPC_TYPE registerMethod | ( | const char * | public_name, |
void(*)(MbedJSONValue &val, MbedJSONValue &res) | fn | ||
) |
Register a procedure.
- Parameters:
-
public_name the method will be seen and called by this name fn the procedure to register (this procedure must have this signature: void fn(MbedJSONValue& val, MbedJSONValue& res)
- Returns:
- if REGISTER_OK, the procedure is registered, otherwise, there is an error
Definition at line 111 of file MbedJSONRpc.cpp.
RPC_TYPE registerMethod | ( | const char * | public_name, |
T * | obj_ptr, | ||
void(T::*)(MbedJSONValue &val, MbedJSONValue &res) | fn | ||
) |
Register a method of an object.
- Parameters:
-
public_name the method will be seen and called by this name obj_ptr a pointeur on the object which contains the method to register fn the method to register (this method must have this signature: void fn(MbedJSONValue& val, MbedJSONValue& res)
- Returns:
- if REGISTER_OK, the method is registered, otherwise, there is an error
Definition at line 131 of file MbedJSONRpc.h.
void work | ( | ) |
Generated on Wed Jul 20 2022 02:14:25 by
