NAME

gc_clients_cleanup - cleans the GC library, frees resources, closes connections.

SYNOPSIS

#include <game-carrier/client.h>

GC_CLIENT_API
void gc_clients_cleanup(void);

RETURN VALUE

None.

DESCRIPTION

The gc_clients_cleanup function is used to clean up the Game Carrier client library, freeing all allocated resources, stopping and closing all open connections, and stopping the service thread in Active and Hybrid modes. It should be called when the library is no longer needed.

For more information about the service thread modes, refer to the gc_clients_service function.

After completing the usage of the Game Carrier client library, you can re-use it again by calling gc_clients_init function. The memory allocation statistics will be printed to a log with a normal log level. In the event of memory leaks, they will be printed with an error log level for identification and resolution.

EXAMPLE

#include <game-carrier/client.h>

#include <stdio.h>

int mode = GC_MODE_HYBRID;
int finished = 0;

int main(int argc, char * argv[])
{
    /* Client library initialization */
    int ret = gc_clients_init(mode);
    if (ret != 0) {
        fprintf(stderr, "Failed to initialize the Game Carrier client library\n");
        return 1;
    }

    /* Game loop */
    while (!finished) {

        /* Perform related game activity, like drawing a new frame */
        draw_new_frame();

        /* Handling network */
        if (mode == GC_MODE_PASSIVE || mode == GC_MODE_HYBRID) {
            gc_clients_service();
        }
    }

    /* Client library finalization */
    gc_clients_cleanup();
    return 0;
}

SEE ALSO

gc_clients_init