NAME
gc_clients_setopt - allows configuring the client initialization parameters.
SYNOPSIS
#include <game-carrier/client.h>
GC_CLIENT_API
GCT_INT gc_clients_setopt(
GCT_CSTR name,
GCT_INT opt_type,
GCT_CPTR value);
Parameters:
nameGCT_CSTRName of the option to include in the invocation.opt_typeGCT_INTData type related to a specific option.valueGCT_CPTRPointer to the value in theopt_typeparameter.
RETURN VALUE
Returns 0 if the operation is successful.
Otherwise, may return one of the following errors:
| Error | Reason |
|---|---|
| EINVAL | The library is already initialized. |
| EINVAL | The specified option is not found. |
| EINVAL | The option has a wrong data type or the value is out of range. |
DESCRIPTION
The gc_clients_setopt function allows configuring the client initialization
parameters, and it must be used before the client initalization
gc_clients_init.
The name parameter identifies the name of option to include in the invocation.
Find all supported option types in the table below.
The opt_type parameter represents a data type related to a specific option.
Supported values: GC_OPT_TYPE_NULL (0), GC_OPT_TYPE_STRING (1),
GC_OPT_TYPE_UINT64 (2), GC_OPT_TYPE_INT (3).
The value parameter identifies a pointer to the value designated as the
opt_type parameter.
Find all supported options in the following table:
| Option Name | Data Type | Description |
|---|---|---|
“max_client_connections” |
GC_OPT_TYPE_UINT64 |
Sets the maximum number of client connections. |
EXAMPLE
#include <game-carrier/client.h>
#include <stdint.h>
uint64_t max_connections = 42;
int main(int argc, char * argv[])
{
gc_log_setopt(GCL_ERR | GCL_WARN | GCL_NOTICE, "game.%p.log", GCL_TO_STDERR);
GCT_INT ret = gc_clients_setopt(
"max_client_connections",
GC_OPT_TYPE_UINT64,
&max_connections);
if (ret != 0) {
gc_log_message(GCL_ERR, "Cannot set a maximum connection count");
return 1;
}
gc_clients_init(GC_MODE_HYBRID);
/* Continue working ............. */
return 0;
}