Remote Procedure Call (RPC) over Websockets (uses MbedJSONValue)

Dependents:   RPC_mbed_client RPC_Wifly_HelloWorld RPC_Ethernet_HelloWorld

Embed: (wiki syntax)

« Back to documentation index

MbedJSONRpc Class Reference

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:
idName of the client on the network
wsAll 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:
fnname of the method or procedure to be called
destname of the client where will be executed the method or procedure
valInput parameters of the method or procedure "fn"
respOnce 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_namethe method will be seen and called by this name
fnthe 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_namethe method will be seen and called by this name
obj_ptra pointeur on the object which contains the method to register
fnthe 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 (  )

Listen for CALL requests.

Warning: infinite loop

Definition at line 130 of file MbedJSONRpc.cpp.