Client functions

Client functions — API for the Remote Procedure Calls

Synopsis

void                (*SPRpcResponse)                    (SPRpc *rpc,
                                                         SPRpcResponseID response_id,
                                                         SPRpcParams *params,
                                                         gpointer user_data);
typedef             SPRpcResponseID;
enum                SPRpcReqType;
SPRpcStatus         sp_rpc_call                         (SPRpc *rpc,
                                                         const gchar *method_name,
                                                         SPRpcParams *params,
                                                         SPRpcReqType request_type,
                                                         SPRpcResponseID *response_id,
                                                         SPRpcResponse response_function,
                                                         gpointer user_data);
SPRpcStatus         sp_rpc_call_list                    (SPRpc *rpc,
                                                         SPRpcResponseID *response_id,
                                                         SPRpcResponse response_function,
                                                         gpointer user_data);
void                sp_rpc_call_remove                  (SPRpc *rpc,
                                                         SPRpcResponseID response_id);
gboolean            sp_rpc_call_is_registered           (SPRpc *rpc,
                                                         SPRpcResponseID response_id);

Description

This part describes the API for the clients and how to exec remote procedure calls

Details

SPRpcResponse ()

void                (*SPRpcResponse)                    (SPRpc *rpc,
                                                         SPRpcResponseID response_id,
                                                         SPRpcParams *params,
                                                         gpointer user_data);

This is the propotype of the callback for the client.

rpc :

a SPRpc

response_id :

the ID of this response

params :

a SPRpcParams

user_data :

the user data

SPRpcResponseID

typedef gint SPRpcResponseID;

The ID of a response operation.


enum SPRpcReqType

typedef enum
{
  SP_RPC_REQ_TYPE_CALL	= 0,
  SP_RPC_REQ_TYPE_GET_PARAMS,
  SP_RPC_REQ_TYPE_EXISTS
} SPRpcReqType;

This is the list of the request type.

SP_RPC_REQ_TYPE_CALL

it calls a method

SP_RPC_REQ_TYPE_GET_PARAMS

it asks the list of the params of a method

SP_RPC_REQ_TYPE_EXISTS

it asks if a method exists. Only the servers with that method return a response.

sp_rpc_call ()

SPRpcStatus         sp_rpc_call                         (SPRpc *rpc,
                                                         const gchar *method_name,
                                                         SPRpcParams *params,
                                                         SPRpcReqType request_type,
                                                         SPRpcResponseID *response_id,
                                                         SPRpcResponse response_function,
                                                         gpointer user_data);

Sends the request for the remote procedure call. The params must be compatible with the called method.

If response_function is not NULL, it will be called with params when the remote method returns them.

rpc :

a SPRpc

method_name :

the method name

params :

the params to send

request_type :

the type of the request

response_id :

the location of a ID, or NULL

response_function :

the pointer of the callback, or NULL

user_data :

data to pass to the function calls

Returns :

a status about the message

sp_rpc_call_list ()

SPRpcStatus         sp_rpc_call_list                    (SPRpc *rpc,
                                                         SPRpcResponseID *response_id,
                                                         SPRpcResponse response_function,
                                                         gpointer user_data);

Sends the request for the list of the calls

rpc :

a SPRpc

response_id :

a location of the response ID, or NULL

response_function :

the pointer of the callback

user_data :

data to pass to the function calls

Returns :

the status of the operation

sp_rpc_call_remove ()

void                sp_rpc_call_remove                  (SPRpc *rpc,
                                                         SPRpcResponseID response_id);

Removes the calling operation from a SPRpc. Any other value from the request will be ignored.

rpc :

a SPRpc

response_id :

the ID of the calling operation

sp_rpc_call_is_registered ()

gboolean            sp_rpc_call_is_registered           (SPRpc *rpc,
                                                         SPRpcResponseID response_id);

Returns TRUE if the response_id is valid and registered to the SPRpc.

rpc :

a SPRpc

response_id :

the ID of the calling operation

Returns :

TRUE/FALSE