Page cover image

Lobby Member Data

Like what your seeing?

Introduction

using HeathenEngineering.SteamworksIntegration;
public struct LobbyMemberData

LobbyMemberData is a structure that wraps around LobbyData and UserData to simplify access to the lobby member metadata and related features for a specific user on a specific lobby. In most cases, you would be working with the LobbyMemberData of the local user and can easily create the LobbyMemberData by reading it from the related lobby.

//Assuming we have a Lobby named myLobby
//We can get our LobbyMember by reading the me field
LobbyMemberData lobbyMember = myLobby.Me;

The most common thing to do with a LobbyMemberData is to set the metadata of that member.

lobbyMember["fieldName"] = "fieldValue";

You can learn more about Lobby metadata and LobbyMemberData metadata by reading this article.

This struct represents a user in a given lobby.

You can get a list of the LobbyMemberData's in a Lobby or you can create the LobbyMemberData assuming you know the Lobby ID and the User's ID i.e.

var myMember = new LobbyMemberData { lobby = thisLobby, user = UserData.Me };

Is the exact same data as

var myMember = thisLobby.User;

which is the same data as

var myMember = thisLobby.Members.First(p => p.user = UserData.Me);

Fields and Attributes

Lobby

The ID of the lobby this member is a member of

public LobbyData lobby;

User

The ID of the user this represents

public UserData user;

Is Ready

A shortcut to read or write the user's lobby member metadata for the field z_heathenReady

public bool IsReady { get; set; }

This is the same as calling

lobbyMember["z_heathenReady"] = value.ToString();

to set a value or

var valueAsBool = bool.Parse(lobbyMember["z_heathenReady"]);

The read the value as a bool

Game Version

A shortcut to read or write the user's lobby member metadata for the field z_heathenGameVersion

This is the same as calling

lobbyMember["z_heathenGameVersion"] = versionAsString;

to set a value or

var versionAsString = bool.Parse(lobbyMember["z_heathenGameVersion"]);

The read the value as a bool

Methods

this[string key]

public string this[string key];

Can be used to get or set metadata values on this user. Only the user its self can set metadata values.

Kick

public void Kick();

Kick this user from this lobby using the Heathen Kick list

Get

public static LobbyMemberData Get(LobbyData lobby, UserData user);

This returns a lobby member data object for the indicated user, in the indicated lobby ... this assumes the member is in the lobby it does not test for this.

Generally your better to use

if(lobby.GetMember(UserData user, out LobbyMemberData memberData)
{
    //The user is a member of the lobby memberData is valid
}
else
{
    //The user is not a member of this lobby, member data is not valid
}

Last updated