Skip to content
modkitv0.2

lobby.h

#include <modkit/lobby.h>34 functions · 10 structs · 5 enums · 18 typedefs · 9 macros

Optional lobbies, invites, and matchmaking.

Enabled with MODKIT_ENABLE_LOBBY, which implies MODKIT_ENABLE_SERVICES. Disabled builds keep the same API and answer MK_ERROR_UNSUPPORTED. A lobby here is a directory service, not a transport: it gives you a member list plus key/value metadata, and the host advertises a connect string the others hand to mk_host_connect_url(). Gameplay traffic stays on modkit/peer.h. That boundary is deliberate a relay transport is a separate project, not a lobby feature. Two backends are possible, and that is the whole set. Steam has a real lobby service; everything else goes through a room server you run, because Play Games retired real-time multiplayer and Game Center's GKMatch is a transport rather than a directory. Query mk_lobby_capabilities() rather than testing platform macros.

Functions

mk_lobby_backend_kindfunction

mk_lobby_backend mk_lobby_backend_kind(void)

Perform the lobby backend kind operation.

Returns The resulting value.

mk_lobby_backend_namefunction

const char * mk_lobby_backend_name(void)

Perform the lobby backend name operation.

Returns A borrowed pointer, or NULL when unavailable.

mk_lobby_capabilitiesfunction

mk_lobby_capabilities_t mk_lobby_capabilities(void)

Perform the lobby capabilities operation.

Returns The resulting handle or value.

mk_lobby_connect_info_getfunction

bool mk_lobby_connect_info_get(mk_lobby_t lobby, mk_lobby_connect_info *out_info)

Get state from the lobby connect info.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
out_infomk_lobby_connect_info *Receives the info.

Returns True when the operation succeeds.

mk_lobby_connect_info_initfunction

void mk_lobby_connect_info_init(mk_lobby_connect_info *info)

Initialize the lobby connect info.

ParameterTypeDescription
infomk_lobby_connect_info *Value for info.

mk_lobby_create_asyncfunction

mk_result mk_lobby_create_async(const mk_lobby_create_desc *desc, mk_lobby_result_fn callback, void *user_data, mk_async_request_t *out_request)

Create async for the lobby.

ParameterTypeDescription
descconst mk_lobby_create_desc *Configuration descriptor.
callbackmk_lobby_result_fnCompletion callback.
user_datavoid *Caller-provided context.
out_requestmk_async_request_t *Receives the request.

Returns MK_SUCCESS or an error result.

mk_lobby_create_desc_initfunction

void mk_lobby_create_desc_init(mk_lobby_create_desc *desc)

Create desc init for the lobby.

ParameterTypeDescription
descmk_lobby_create_desc *Configuration descriptor.

mk_lobby_data_atfunction

bool mk_lobby_data_at(mk_lobby_t lobby, uint32_t index, mk_lobby_kv *out_kv)

Perform the lobby data at operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
indexuint32_tZero-based index.
out_kvmk_lobby_kv *Receives the kv.

Returns True when the operation succeeds.

mk_lobby_data_countfunction

uint32_t mk_lobby_data_count(mk_lobby_t lobby)

Perform the lobby data count operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.

Returns The resulting value.

mk_lobby_desc_initfunction

void mk_lobby_desc_init(mk_lobby_desc *desc)

Initialize the lobby desc.

ParameterTypeDescription
descmk_lobby_desc *Configuration descriptor.

mk_lobby_get_datafunction

const char * mk_lobby_get_data(mk_lobby_t lobby, const char *key)

Get data from the lobby.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
keyconst char *Value for key.

Returns A borrowed pointer, or NULL when unavailable.

mk_lobby_get_member_datafunction

const char * mk_lobby_get_member_data(mk_lobby_t lobby, const char *player_id, const char *key)

Get member data from the lobby.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
player_idconst char *Value for player ID.
keyconst char *Value for key.

Returns A borrowed pointer, or NULL when unavailable.

mk_lobby_hostfunction

bool mk_lobby_host(mk_lobby_t lobby, mk_lobby_member *out_member)

Perform the lobby host operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
out_membermk_lobby_member *Receives the member.

Returns True when the operation succeeds.

mk_lobby_idfunction

bool mk_lobby_id(mk_lobby_t lobby, char *out_id, size_t capacity)

Perform the lobby ID operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
out_idchar *Receives the ID.
capacitysize_tValue for capacity.

Returns True when the operation succeeds.

mk_lobby_initfunction

mk_result mk_lobby_init(const mk_lobby_desc *desc)

Initialize the lobby.

ParameterTypeDescription
descconst mk_lobby_desc *Configuration descriptor.

Returns MK_SUCCESS or an error result.

mk_lobby_invitefunction

mk_result mk_lobby_invite(mk_lobby_t lobby, const char *player_id)

Perform the lobby invite operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
player_idconst char *Value for player ID.

Returns MK_SUCCESS or an error result.

mk_lobby_invite_stringfunction

bool mk_lobby_invite_string(mk_lobby_t lobby, char *out_text, size_t capacity)

A shareable join token for backends with no platform invite UI.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
out_textchar *Receives the text.
capacitysize_tValue for capacity.

Returns True when the operation succeeds.

mk_lobby_is_hostfunction

bool mk_lobby_is_host(mk_lobby_t lobby)

Test whether the lobby is host.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.

Returns True when the condition holds.

mk_lobby_is_initializedfunction

bool mk_lobby_is_initialized(void)

Test whether the lobby is initialized.

Returns True when the condition holds.

mk_lobby_join_asyncfunction

mk_result mk_lobby_join_async(const char *lobby_id, mk_lobby_result_fn callback, void *user_data, mk_async_request_t *out_request)

Perform the lobby join async operation.

ParameterTypeDescription
lobby_idconst char *Value for lobby ID.
callbackmk_lobby_result_fnCompletion callback.
user_datavoid *Caller-provided context.
out_requestmk_async_request_t *Receives the request.

Returns MK_SUCCESS or an error result.

mk_lobby_last_errorfunction

mk_lobby_error mk_lobby_last_error(void)

Perform the lobby last error operation.

Returns The resulting value.

mk_lobby_leavefunction

mk_result mk_lobby_leave(mk_lobby_t lobby)

Leave and invalidate the handle.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.

Returns MK_SUCCESS or an error result.

mk_lobby_list_asyncfunction

mk_result mk_lobby_list_async(const mk_lobby_query_desc *query, mk_lobby_list_fn callback, void *user_data, mk_async_request_t *out_request)

Perform the lobby list async operation.

ParameterTypeDescription
queryconst mk_lobby_query_desc *Value for query.
callbackmk_lobby_list_fnCompletion callback.
user_datavoid *Caller-provided context.
out_requestmk_async_request_t *Receives the request.

Returns MK_SUCCESS or an error result.

mk_lobby_member_atfunction

bool mk_lobby_member_at(mk_lobby_t lobby, uint32_t index, mk_lobby_member *out_member)

Perform the lobby member at operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
indexuint32_tZero-based index.
out_membermk_lobby_member *Receives the member.

Returns True when the operation succeeds.

mk_lobby_member_countfunction

uint32_t mk_lobby_member_count(mk_lobby_t lobby)

Perform the lobby member count operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.

Returns The resulting value.

mk_lobby_pollfunction

uint32_t mk_lobby_poll(uint32_t max_events)

Deliver pending lobby events and request completions.

Unlike services, this is app-driven: lobby events are gameplay-affecting and belong inside your own state machine. Returns the number of callbacks delivered; max_events of zero drains everything ready.

ParameterTypeDescription
max_eventsuint32_tValue for max events.

Returns The resulting value.

mk_lobby_query_desc_initfunction

void mk_lobby_query_desc_init(mk_lobby_query_desc *desc)

Query desc init for the lobby.

ParameterTypeDescription
descmk_lobby_query_desc *Configuration descriptor.

mk_lobby_set_datafunction

mk_result mk_lobby_set_data(mk_lobby_t lobby, const char *key, const char *value)

Set data on the lobby.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
keyconst char *Value for key.
valueconst char *Value to use.

Returns MK_SUCCESS or an error result.

mk_lobby_set_member_datafunction

mk_result mk_lobby_set_member_data(mk_lobby_t lobby, const char *key, const char *value)

Writes only your own row, which is the rule every backend enforces.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
keyconst char *Value for key.
valueconst char *Value to use.

Returns MK_SUCCESS or an error result.

mk_lobby_show_invite_uifunction

mk_result mk_lobby_show_invite_ui(mk_lobby_t lobby)

Perform the lobby show invite UI operation.

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.

Returns MK_SUCCESS or an error result.

mk_lobby_shutdownfunction

void mk_lobby_shutdown(void)

Perform the lobby shutdown operation.

mk_lobby_startfunction

mk_result mk_lobby_start(mk_lobby_t lobby, const mk_lobby_connect_info *info)

Host only: publish where gameplay traffic should connect.

Every member then receives MK_LOBBY_EVENT_GAME_STARTED and can read the same details with mk_lobby_connect_info_get().

ParameterTypeDescription
lobbymk_lobby_tValue for lobby.
infoconst mk_lobby_connect_info *Value for info.

Returns MK_SUCCESS or an error result.

mk_lobby_take_pending_joinfunction

bool mk_lobby_take_pending_join(char *out_lobby_id, size_t capacity)

Consume a lobby id delivered before the app was ready, as when an invite launched the process.

Returns true once, then false.

ParameterTypeDescription
out_lobby_idchar *Receives the lobby ID.
capacitysize_tValue for capacity.

Returns True when the operation succeeds.

mk_lobby_validfunction

bool mk_lobby_valid(mk_lobby_t handle)

Perform the lobby valid operation.

ParameterTypeDescription
handlemk_lobby_tValue for handle.

Returns True when the operation succeeds.

Structs

mk_lobby_connect_infostruct

Where gameplay traffic should connect once the host starts the session.

The lobby does not carry gameplay traffic. Non-hosts pass url to mk_host_connect_url(), or host/port to mk_host_connect().

FieldTypeDescription
struct_sizeuint32_tThe struct size.
struct_versionuint32_tThe struct version.
hostcharThe host.
portuint16_tThe port.
urlcharThe URL.
host_player_idcharThe host player ID.
session_nonceuint64_tHost-generated join token, if the app uses one.

mk_lobby_create_descstruct

Data for lobby create desc.

FieldTypeDescription
struct_sizeuint32_tThe struct size.
struct_versionuint32_tThe struct version.
visibilitymk_lobby_visibilityThe visibility.
max_membersuint32_tThe max members.
dataconst mk_lobby_kv *Applied as the lobby is created.
data_countuint32_tThe data count.

mk_lobby_descstruct

Data for lobby desc.

FieldTypeDescription
struct_sizeuint32_tThe struct size.
struct_versionuint32_tThe struct version.
preferred_backendmk_lobby_backendThe preferred backend.
server_urlconst char *ws:// or wss:// room server for the SERVER backend.
event_fnmk_lobby_event_fnThe event.
event_user_datavoid *The event user data.

mk_lobby_errorstruct

Detail carried alongside mk_result.

mk_result has no NOT_FOUND, TIMEOUT, or NETWORK value, so lobby failures map onto the closest mk_result and carry the real reason here the same split mk_net_error uses.

FieldTypeDescription
codemk_lobby_error_codeThe code.
platform_codeint32_tThe platform code.
messagecharThe message.

mk_lobby_eventstruct

Data for lobby event.

FieldTypeDescription
typemk_lobby_event_typeThe type.
lobbymk_lobby_tThe lobby.
lobby_idcharSet for JOIN_REQUESTED, where lobby is invalid.
membermk_lobby_memberThe member.
errormk_lobby_errorThe error.

mk_lobby_handlestruct

Data for lobby handle.

FieldTypeDescription
iduint32_tThe ID.

mk_lobby_kvstruct

Data for lobby kv.

FieldTypeDescription
keycharThe key.
valuecharThe value.

mk_lobby_memberstruct

Data for lobby member.

FieldTypeDescription
player_idcharThe player ID.
display_namecharThe display name.
is_hostboolThe is host.

mk_lobby_query_descstruct

Data for lobby query desc.

FieldTypeDescription
struct_sizeuint32_tThe struct size.
struct_versionuint32_tThe struct version.
filtersconst mk_lobby_kv *Exact string matches on lobby data.
filter_countuint32_tThe filter count.
min_slots_availableuint32_tThe min slots available.
max_resultsuint32_tThe max results.

mk_lobby_summarystruct

Data for lobby summary.

FieldTypeDescription
lobby_idcharThe lobby ID.
member_countuint32_tThe member count.
max_membersuint32_tThe max members.
dataconst mk_lobby_kv *Valid for the callback only.
data_countuint32_tThe data count.

Enums

mk_lobby_backendenum

Values for lobby backend.

ValueDescription
MK_LOBBY_BACKEND_AUTOSelects auto.
MK_LOBBY_BACKEND_NONESelects none.
MK_LOBBY_BACKEND_FAKEIn-process; for tests and offline development.
MK_LOBBY_BACKEND_STEAMSelects steam.
MK_LOBBY_BACKEND_SERVERA room server you host.

mk_lobby_capabilityenum

Values for lobby capability.

ValueDescription
MK_LOBBY_CAP_CREATESelects create.
MK_LOBBY_CAP_LISTPublic lobby search.
MK_LOBBY_CAP_STRING_FILTERSelects string filter.
MK_LOBBY_CAP_NUMERIC_FILTERSelects numeric filter.
MK_LOBBY_CAP_MEMBER_DATASelects member data.
MK_LOBBY_CAP_INVITE_DIRECTInvite a known player id.
MK_LOBBY_CAP_INVITE_OVERLAYPlatform invite UI.
MK_LOBBY_CAP_JOIN_ON_LAUNCHInvite accepted before the app was ready.
MK_LOBBY_CAP_CHATReserved; not in this version.
MK_LOBBY_CAP_RELAY_TRANSPORTReserved; always clear today.

mk_lobby_error_codeenum

Values for lobby error code.

ValueDescription
MK_LOBBY_ERROR_NONESelects none.
MK_LOBBY_ERROR_UNSUPPORTEDSelects unsupported.
MK_LOBBY_ERROR_NOT_SIGNED_INSelects not signed in.
MK_LOBBY_ERROR_FULLSelects full.
MK_LOBBY_ERROR_NOT_FOUNDSelects not found.
MK_LOBBY_ERROR_BANNEDSelects banned.
MK_LOBBY_ERROR_NETWORKSelects network.
MK_LOBBY_ERROR_TIMEOUTSelects timeout.
MK_LOBBY_ERROR_PLATFORMSelects platform.

mk_lobby_event_typeenum

Values for lobby event type.

ValueDescription
MK_LOBBY_EVENT_MEMBER_JOINEDSelects member joined.
MK_LOBBY_EVENT_MEMBER_LEFTSelects member left.
MK_LOBBY_EVENT_DATA_CHANGEDSelects data changed.
MK_LOBBY_EVENT_MEMBER_DATA_CHANGEDSelects member data changed.
MK_LOBBY_EVENT_HOST_CHANGEDSelects host changed.
MK_LOBBY_EVENT_GAME_STARTEDConnect info is now readable.
MK_LOBBY_EVENT_KICKEDThe handle is terminal after this.
MK_LOBBY_EVENT_JOIN_REQUESTEDAn invite was accepted; you have NOT joined.
MK_LOBBY_EVENT_DISCONNECTEDSelects disconnected.

mk_lobby_visibilityenum

Values for lobby visibility.

ValueDescription
MK_LOBBY_PRIVATEInvite only.
MK_LOBBY_FRIENDSSelects friends.
MK_LOBBY_PUBLICSelects public.
MK_LOBBY_INVISIBLEJoinable by id but not listed.

Typedefs

mk_lobby_backendtypedef

typedef enum mk_lobby_backend mk_lobby_backend

Values for lobby backend.

mk_lobby_capabilities_ttypedef

typedef uint64_t mk_lobby_capabilities_t

Type used for lobby capabilities.

mk_lobby_connect_infotypedef

typedef struct mk_lobby_connect_info mk_lobby_connect_info

Where gameplay traffic should connect once the host starts the session.

The lobby does not carry gameplay traffic. Non-hosts pass url to mk_host_connect_url(), or host/port to mk_host_connect().

mk_lobby_create_desctypedef

typedef struct mk_lobby_create_desc mk_lobby_create_desc

Data for lobby create desc.

mk_lobby_desctypedef

typedef struct mk_lobby_desc mk_lobby_desc

Data for lobby desc.

mk_lobby_errortypedef

typedef struct mk_lobby_error mk_lobby_error

Detail carried alongside mk_result.

mk_result has no NOT_FOUND, TIMEOUT, or NETWORK value, so lobby failures map onto the closest mk_result and carry the real reason here the same split mk_net_error uses.

mk_lobby_error_codetypedef

typedef enum mk_lobby_error_code mk_lobby_error_code

Values for lobby error code.

mk_lobby_eventtypedef

typedef struct mk_lobby_event mk_lobby_event

Data for lobby event.

mk_lobby_event_fntypedef

typedef void(*) mk_lobby_event_fn(const mk_lobby_event *event, void *user_data)

Lobby state change.

Delivered from mk_lobby_poll(); valid for the call only.

mk_lobby_event_typetypedef

typedef enum mk_lobby_event_type mk_lobby_event_type

Values for lobby event type.

mk_lobby_kvtypedef

typedef struct mk_lobby_kv mk_lobby_kv

Data for lobby kv.

mk_lobby_list_fntypedef

typedef void(*) mk_lobby_list_fn(mk_async_request_t request, mk_result result, const mk_lobby_error *error, const mk_lobby_summary *lobbies, uint32_t count, void *user_data)

Callback used for lobby list.

mk_lobby_membertypedef

typedef struct mk_lobby_member mk_lobby_member

Data for lobby member.

mk_lobby_query_desctypedef

typedef struct mk_lobby_query_desc mk_lobby_query_desc

Data for lobby query desc.

mk_lobby_result_fntypedef

typedef void(*) mk_lobby_result_fn(mk_async_request_t request, mk_result result, const mk_lobby_error *error, mk_lobby_t lobby, void *user_data)

Callback used for lobby result.

mk_lobby_summarytypedef

typedef struct mk_lobby_summary mk_lobby_summary

Data for lobby summary.

mk_lobby_ttypedef

typedef struct mk_lobby_handle mk_lobby_t

Data for lobby handle.

mk_lobby_visibilitytypedef

typedef enum mk_lobby_visibility mk_lobby_visibility

Values for lobby visibility.

Macros

MK_LOBBY_CONNECT_INFO_VERSIONdefine

MK_LOBBY_CONNECT_INFO_VERSION

ABI or format version for lobby connect info.

MK_LOBBY_CREATE_DESC_VERSIONdefine

MK_LOBBY_CREATE_DESC_VERSION

ABI or format version for lobby create desc.

MK_LOBBY_DESC_VERSIONdefine

MK_LOBBY_DESC_VERSION

ABI or format version for lobby desc.

MK_LOBBY_INVALIDdefine

MK_LOBBY_INVALID

Invalid sentinel for lobby.

MK_LOBBY_MAX_IDdefine

MK_LOBBY_MAX_ID

Maximum supported lobby ID.

MK_LOBBY_MAX_KEYdefine

MK_LOBBY_MAX_KEY

Maximum supported lobby key.

MK_LOBBY_MAX_NAMEdefine

MK_LOBBY_MAX_NAME

Maximum supported lobby name.

MK_LOBBY_MAX_VALUEdefine

MK_LOBBY_MAX_VALUE

Maximum supported lobby value.

MK_LOBBY_QUERY_DESC_VERSIONdefine

MK_LOBBY_QUERY_DESC_VERSION

ABI or format version for lobby query desc.