Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/lobbies.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,55 @@
* @func_end
*/

/**
* @func steam_lobby_request_data
* @desc This function requests a metadata refresh for the given lobby ID. This is useful when you have a lobby ID from ${function.steam_get_friends_game_info} or a previous lobby list and want to read its latest lobby fields without joining it.
*
* @param {int64} lobby_id Identifier of the lobby to refresh metadata for
*
* @returns {boolean}
*
* @event steam
* @member {string} event_type The string value `"lobby_data_update"`
* @member {int64} lobby_id The lobby unique identifier
* @member {int64} member_id The lobby ID again for lobby metadata updates, or a member Steam ID for member data updates
* @member {boolean} success Whether or not the lobby data refresh was successful
* @member {real} result The code of the result
* @event_end
*
* @example
* ```gml
* var _friend_info = steam_get_friends_game_info(_friend_id);
* if (_friend_info.lobbyId != 0)
* {
* steam_lobby_request_data(_friend_info.lobbyId);
* }
* ```
* The code above requests the latest metadata for a friend's lobby. Handle the `"lobby_data_update"` Steam async event before reading the fields with ${function.steam_lobby_get_data_by_id}.
* @func_end
*/

/**
* @func steam_lobby_get_data_by_id
* @desc This function returns a cached lobby field value for the given lobby ID, as set by ${function.steam_lobby_set_data}. Use ${function.steam_lobby_request_data} first if you need to refresh metadata for a lobby you are not currently in.
*
* @param {int64} lobby_id Identifier of the lobby to read cached metadata from
* @param {string} key String representation of the data
*
* @returns {string}
*
* @example
* ```gml
* if (async_load[? "event_type"] == "lobby_data_update" && async_load[? "success"])
* {
* var _lobby_id = async_load[? "lobby_id"];
* var _title = steam_lobby_get_data_by_id(_lobby_id, "title");
* }
* ```
* The code above reads the cached `title` field after Steam reports that the lobby metadata was refreshed.
* @func_end
*/

/**
* @func steam_lobby_get_lobby_id
* @desc This function returns the Steam ID of the current lobby.
Expand Down Expand Up @@ -847,12 +896,14 @@
* @ref steam_lobby_list_request
* @ref steam_lobby_list_get_count
* @ref steam_lobby_list_get_data
* @ref steam_lobby_get_data_by_id
* @ref steam_lobby_list_get_lobby_id
* @ref steam_lobby_list_get_lobby_member_count
* @ref steam_lobby_list_get_lobby_member_id
* @ref steam_lobby_list_get_lobby_owner_id
* @ref steam_lobby_list_is_loading
* @ref steam_lobby_list_join
* @ref steam_lobby_request_data
* @section_end
*
* @section_const Constants
Expand Down
4 changes: 3 additions & 1 deletion source/Steamworks_gml/extensions/steamworks/Steamworks.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class steam_net_callbacks_t
};
STEAM_CALLBACK(steam_net_callbacks_t, p2p_session_request, P2PSessionRequest_t);
//STEAM_CALLBACK(steam_net_callbacks_t, OnPersonaStateChange, PersonaStateChange_t);
STEAM_CALLBACK(steam_net_callbacks_t, lobby_data_update, LobbyDataUpdate_t);
STEAM_CALLBACK(steam_net_callbacks_t, lobby_chat_update, LobbyChatUpdate_t);
STEAM_CALLBACK(steam_net_callbacks_t, lobby_chat_message, LobbyChatMsg_t);
STEAM_CALLBACK(steam_net_callbacks_t, lobby_join_requested, GameLobbyJoinRequested_t);
Expand Down Expand Up @@ -43,4 +44,4 @@ class steam_net_callbacks_t
void parties_change_num_open_slots(ChangeNumOpenSlotsCallback_t* e, bool failed);
void parties_join_party(JoinPartyCallback_t* e, bool failed);
};
extern steam_net_callbacks_t steam_net_callbacks;
extern steam_net_callbacks_t steam_net_callbacks;
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ YYEXPORT void /*double*/ steam_lobby_create(RValue& Result, CInstance* selfinst,

#pragma region Managing lobbies

void steam_net_callbacks_t::lobby_data_update(LobbyDataUpdate_t* e)
{
steam_net_event q((char*)"lobby_data_update");
q.set_uint64_all("lobby_id", e->m_ulSteamIDLobby);
q.set_uint64_all("member_id", e->m_ulSteamIDMember);
q.set_success(e->m_bSuccess);
q.dispatch();
}

/// [lobby owner only] Sets the data for the current lobby.
YYEXPORT void /*double*/ steam_lobby_set_data(RValue& Result, CInstance* selfinst, CInstance* otherinst, int argc, RValue* arg)//(char* key, char* value)
{
Expand Down Expand Up @@ -544,6 +553,38 @@ YYEXPORT void /*char**/ steam_lobby_get_data(RValue& Result, CInstance* selfinst
else YYCreateString(&Result, "");
}

/// [anyone] Requests a metadata refresh for the given lobby.
YYEXPORT void /*double*/ steam_lobby_request_data(RValue& Result, CInstance* selfinst, CInstance* otherinst, int argc, RValue* arg)//(int64 lobby_id)
{
uint64 lobby_id = (uint64)YYGetInt64(arg, 0);

Result.kind = VALUE_BOOL;
if (SteamMatchmaking())
{
Result.val = SteamMatchmaking()->RequestLobbyData(CSteamID(lobby_id));
}
else
{
Result.val = false;
}
}

/// [anyone] Retrieves cached data for the given lobby.
YYEXPORT void /*char**/ steam_lobby_get_data_by_id(RValue& Result, CInstance* selfinst, CInstance* otherinst, int argc, RValue* arg)//(int64 lobby_id, char* key)
{
uint64 lobby_id = (uint64)YYGetInt64(arg, 0);
char* key = (char*)YYGetString(arg, 1);

if (SteamMatchmaking())
{
YYCreateString(&Result, SteamMatchmaking()->GetLobbyData(CSteamID(lobby_id), key));
}
else
{
YYCreateString(&Result, "");
}
}

/// [lobby owner only] Changes the type of the current lobby.
YYEXPORT void /*double*/ steam_lobby_set_type(RValue& Result, CInstance* selfinst, CInstance* otherinst, int argc, RValue* arg)//(double type)
{
Expand Down