NAME

application_initialize - initializes the application and determines its readiness.

SYNOPSIS

#include <game-carrier/server.h>

GC_ADAPTER_EVENT
GCT_INT application_initialize(
    GCT_INT app_id,
    GCT_CSTR name,
    GCT_CSTR type_name,
    GCT_CSTR file_name);

Parameters:

  • app_id GCT_INT Unique identifier of the application.
  • name GCT_CSTR Unique name of the application.
  • type_name GCT_CSTR Class type name.
  • file_name GCT_CSTR Name of the application source file.

RETURN VALUE

Returns 0 upon successful execution.

A non-zero value indicates an error, prompting the loading gcs to halt in such cases.

DESCRIPTION

The application_initialize function is invoked by the gcs for every application specified in the server’s configuration file. Its purpose is to initialize the application and determine its readiness. Upon successful initialization, the function returns 0, while a non-zero value indicates an error. In case of an error, the gcs will halt the loading process for the respective application.

The app_id parameter represents the unique identifier of the application. This value is used to make the discovery of the adapter possible in future calls.

The name parameter is the unqiue name of the application. Games can utilize this name as an identifier to establish connections with specific applications on a server using the WebSocket Secure protocol.

The type_name parameter represents the class type name. It is an arbitrary value that each adapter can utilize according to its specific requirements.

The file_name parameter identifies the name of the application source file. It is an arbitrary value that each adapter can utilize according to its specific requirements.

The type_name and file_name parameters serve the purpose of enabling an adapter to create an application instance dedicated to that specific adapter. Each adapter has the freedom to utilize these parameters as needed to establish an application instance responsible for handling connections.

Typically, the names assigned to type_name and file_name hold informative value, but they may be disregarded depending on the context.

EXAMPLE

#include <game-carrier/server.h>

GC_ADAPTER_EVENT
GCT_INT application_initialize(
    GCT_INT id,
    GCT_CSTR name,
    GCT_CSTR type_name,
    GCT_CSTR file_name)
{
    /**
     * Here is a good place for:
     *   - initialization/allocation global application resources
     *   - creating application related counters
     **/
    return 0;
}

GC_ADAPTER_EVENT
void application_start(
    GCT_INT id)
{
    /**
     * Here is a good place for:
     *   - starting networking activity
     *   - obtaining counter names list
     **/
}

GC_ADAPTER_EVENT
void application_stop(
    GCT_INT id)
{
    /* Here is good place for last networking commucations */
}

GC_ADAPTER_EVENT
void application_shutdown(
    GCT_INT id)
{
    /* Here is good place for deinitialization/deallocation global application resources */
}

SEE ALSO

adapter_initialize, application_stop, application_finalize