![]() |
![]() |
![]() |
Spread RPC - Reference Manual | ![]() |
---|---|---|---|---|
typedef SPRpcMethodID; void (*SPRpcMethod) (SPRpc *rpc, SPRpcMethodID method_id, SPRpcParams *params, SPRpcParams *return_params, gpointer user_data); SPRpcMethodID sp_rpc_register (SPRpc *rpc, const gchar *method_name, const gchar *method_description, SPRpcParams *params, SPRpcMethod method_function, gpointer user_data); void sp_rpc_unregister (SPRpc *rpc, SPRpcMethodID method_id); gboolean sp_rpc_is_registered (SPRpc *rpc, SPRpcMethodID method_id);
void (*SPRpcMethod) (SPRpc *rpc, SPRpcMethodID method_id, SPRpcParams *params, SPRpcParams *return_params, gpointer user_data);
This is the prototype of a method.
|
the SPRpc |
|
the ID of this method |
|
the input params |
|
a SPRpcParams object for the return values. If it is not empty, it will be send as response. |
|
a user data |
SPRpcMethodID sp_rpc_register (SPRpc *rpc, const gchar *method_name, const gchar *method_description, SPRpcParams *params, SPRpcMethod method_function, gpointer user_data);
Adds a new method to a SPRpc. The new method will be call when a request is received by the spread ring.
The params describes the inputs of the method. If you specify the type of the input, they will be validated when a client calls this method. If you specify also a value, if the client doesn't send one of them, it will be created with the value you specified here. Use SP_RPC_VALUE_NULL if you want to accept any kind of value.
If a method with this name already exists, it will be replaced with this new one.
|
a SPRpc |
|
the name of the method |
|
a description of the method or NULL |
|
a SPRpcParams with the SPRpcValues for this method |
|
a pointer to a SPRpcMethod |
|
data to pass to the function calls |
Returns : |
a SPRpcMethodID of the new registerd method |
void sp_rpc_unregister (SPRpc *rpc, SPRpcMethodID method_id);
Removes a SPRpcMethod from the SPRpc.
|
a SPRpc |
|
the ID of the method |
gboolean sp_rpc_is_registered (SPRpc *rpc, SPRpcMethodID method_id);
Returns TRUE if the method ID is valid and registerd into a SPRpc.
|
a SPRpc |
|
the ID of the method |
Returns : |
TRUE or FALSE |