Skip to content

rc_client_create

Jamiras edited this page Nov 1, 2023 · 5 revisions

Creates a new rc_client_t object.

Syntax

rc_client_t* rc_client_create(
    rc_client_read_memory_t read_memory_function,
    rc_client_server_call_t server_call_function
);

Parameters

read_memory_function

Function to read memory from the emulator. More detail at rc_client_set_read_memory_function.

server_call_function

Function to make a request to the server. The emulator must provide it's own HTTP library.


rc_client_server_call_t

void (*rc_client_server_call_t)(
    const rc_api_request_t* request,
    rc_client_server_callback_t callback,
    void* callback_data,
    rc_client_t* client
);

request

Contains the URL to invoke and optional POST data to send to the URL. If POST data is not provided, a GET call should be made.

callback

A function to call when the response is available. It is expected that the server call will be asynchronous.

callback_data

Additional data to pass to callback.

If the server call is made asynchronously, the implementation is responsible for capturing the callback and callback_data pointers for handling the asynchronous response.

client

The rc_client_t that spawned the request.


rc_client_server_callback_t

void (*rc_client_server_callback_t)(
    const rc_api_server_response_t* server_response,
    void* callback_data
);

server_response

The response from the server (normally JSON). Includes the body, length, and HTTP status code.

The server_response object may be a stack variable. It only has to live through the call to the callback.

Regardless of the server call outcome, the callback must be called. You may pass non-HTTP errors through the callback by setting body to the error message (i.e. "Request timed out.") and RC_API_SERVER_RESPONSE_CLIENT_ERROR or RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR as the status code. If the server callback sees RC_API_SERVER_RESPONSE_CLIENT_ERROR it will immediately pass the error on to the original function's callback. If the server callback sees RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR, it may choose to retry the server call, or pass the error on to the original function's callback.

callback_data

The additional data passed to the rc_client_server_call_t.

Remarks

The rc_client_t instance created by this function must be released by calling rc_client_destroy.

Minimum version: 11.0.0

See also

rc_client_destroy

rc_client_enable_logging

rc_client_set_encore_mode_enabled

rc_client_set_hardcore_enabled

rc_client_set_host

rc_client_set_read_memory_function

rc_client_set_spectator_mode_enabled

rc_client_set_unofficial_enabled

rc_client_set_userdata

rcheevos

rc_client

Integration guide

client

user

game

processing

rc_client_raintegration

Integration guide

rc_runtime

rhash

rapi

common

user

runtime

info

Clone this wiki locally