# Lobby Data

The LobbyData object is a custom CSteamId that carries tools and functions unique to the Steam Lobby system. This object is common between both Unity and Godot game engine integrations.

```csharp
using Heathen.SteamworksIntegraiton;
```

You can convert a Lobby to a ulong or CSteamID, or convert a ulong or CSteamID to a Lobby implicitly e.g.&#x20;

```csharp
LobbyData myLobby = new CSteamID(ulongId);
// or
ulong id = myLobby;
// or
CSteamID id = myLobby;
```

All data is read on demand and is always up to date with the Lobby object. The only information it stores in local memory is the ID of the lobby its operating on.&#x20;

## Fields and Attributes

### Account ID

```csharp
public readonly AccountID_t AccountId = get;
```

Returns the native AccountID\_t struct for this lobby; this is read-only.

***

### All Players Not Ready

```csharp
public readonly bool AllPlayersNotReady => get;
```

True if any player in the lobby is not marked as ready.

***

### All Players Ready

```csharp
public readonly bool AllPlayersReady => get;
```

True if all players in the lobby are marked as ready.

***

### Friend ID

```csharp
public readonly uint FriendId => get;
```

Primitive value of the Account ID.

***

### Full

```csharp
public readonly bool Full => get;
```

Returns true if this lobby is full.

***

### Game Server

```csharp
public readonly LobbyGameServer GameServer => get;
```

Lobby Game Server structure provides detailed information about the connection info, if any, on the lobby, including the ID of the Host or Server and the IP:Port if set.

***

### Game Version

```csharp
public readonly string GameVersion { get; set; }
```

Gets or sets the game version string on this lobby. This can only be set by the owner of the lobby, but can be read by any member of the lobby or searched for by using `key=z_heathenGameVersion`

***

### Has Server

```csharp
public readonly bool HasServer => get;
```

True if the lobby has a Game Server value set.

***

### Hex ID

```csharp
public readonly string HexId => get;
```

Gets the Hex ID of the lobby; this is a much more human-friendly value to ask a user to type if you are doing that.

***

### Is Group

```csharp
public readonly bool IsGroup { get; set; }
```

True if this lobby is a group, this can be set by the owner only and will change the lobby type to Invisible if set to true.

***

### Is Owner

```csharp
public readonly bool IsOwner => get;
```

True if the local user is the owner of this lobby.

***

### Is Ready

```csharp
public readonly bool IsReady { get; set; }
```

Returns the local user's ready state and can be set by the local user to update their ready state.

***

### Is Session

```csharp
public readonly bool IsSession { get; set; }
```

True if this lobby is flagged as a session lobby; this can only be set by the owner of the lobby.

***

### Is Type Set

```csharp
public readonly bool IsTypeSet => get;
```

True if the lobby type has been recorded in the metadata, else false.

***

### Is Valid

```csharp
public readonly bool IsValid => get;
```

True if this LobbyData points to a valid lobby CSteamID, this only indicates the value is structurally valid, it doesn't indicate whether or not this lobby exists or is in use.

***

### Max Members

```csharp
public readonly int MaxMembers { get; set; }
```

The maximum number of members this lobby can take, this can be set by the owner of the lobby.

***

### Me

```csharp
public readonly LobbyMemberData Me => get;
```

The member data for this user.

***

### Member Count

```csharp
public readonly int MemberCount => get;
```

The number of members in this lobby.

***

### Members

```csharp
public readonly LobbyMemberData[] Members => get;
```

The collection of all members of this lobby, including the owner of the lobby.

***

### Name

```csharp
public readonly string Name { get; set; }
```

Get or set the lobby name.

***

### Owner

```csharp
public readonly LobbyMemberData Owner { get; set; }
```

The owner of this lobby, the current owner can set this to another member's value to change who the owner is.

***

### Steam ID

```csharp
public readonly CSteamID SteamId => get;
```

Gets the native CSteamID of this lobby.

***

### this\[string metadataKey]

```csharp
public readonly string this[string metadataKey] { get; set; }
```

It can be used to read metadata from the lobby, and can be used by the owner to set metadata on the lobby.

***

### this\[UserData user]

```csharp
public readonly LobbyMemberData this[UserData user] => get;
```

Get the LobbyMemberData of a user, assuming they are a member of the lobby.

***

### Type

```csharp
public readonly ELobbyType Type { get; set; }
```

Read the type of lobby this is, the owner can set this to change the type.

***

## Functions

### Authenticate

```csharp
public readonly void Authenticate(Action<AuthenticationTicket, bool> callback)
// Or
public readonly bool Authenticate(LobbyAuthenticationData data)
```

Sends a chat message to the lobby with authentication data that can be used by the owner of the lobby to validate this user and optionally serialized inventory. Two overloads are available; you can either create your own LobbyAuthenticationData object and pass that in, or you can provide a callback to be invoked on completion, and the system will create a default LobbyAuthenticaitonData for you and send that, invoking the callback once that process has been completed.

Callback example

```csharp
void Callback(AuthenticationTicket ticket, bool ioError)
{
    // ioError true if an error occurred on send
    // ticket the ticket that was sent, if no error
}
```

***

### Clear Kick List

```csharp
public readonly bool ClearKickList()
```

Clears the kick list

***

### Create

```csharp
public static void Create(CreateArguments createArguments, Action<EResult, LobbyData, bool> callback)
// or
public static void Create(ELobbyType type, int slots, Action<EResult, LobbyData, bool> callback)
// or 
public static void CreateParty(int slots, Action<EResult, LobbyData, bool> callback)
// or 
public static void CreateSession(ELobbyType type, int slots, Action<EResult, LobbyData, bool> callback)
// or
public static void CreatePublicSession(int slots, Action<EResult, LobbyData, bool> callback)
// or
public static void CreatePrivateSession(int slots, Action<EResult, LobbyData, bool> callback)
// or
public static void CreateFriendOnlySession(int slots, Action<EResult, LobbyData, bool> callback)
```

Creates a new lobby, multiple overloads act as a shortcut for more or less details, the "native" or general use would be `(type, slots, callback)`. In all cases the callback has the same form.

```csharp
void Callback(EResult Result, LobbyData Lobby, bool IOError)
{
    
}
```

***

### Delete Lobby Data

```csharp
public readonly bool DeleteLobbyData(string dataKey)
```

Removes a key from the lobby metadata.

***

### Get

```csharp
public static LobbyData Get(string accountId)
// or
public static LobbyData Get(uint accountId)
// or
public static LobbyData Get(AccountID_t accountId)
// or
public static LobbyData Get(ulong id)
// or
public static LobbyData Get(CSteamID id)
```

Get a LobbyData based on the provided input.

***

### Get Kick List

```csharp
public readonly UserData[] GetKickList()
```

Gets the list of users that are recorded in the lobby kick list.

***

### Get Member

```csharp
public readonly bool GetMember(UserData user, out LobbyMemberData member)
```

Get the LobbyMember object for a given user. Returns true if the user is a member of the lobby, false if they are not.

***

### Get Member Metadata

```csharp
public readonly string GetMemberMetadata(LobbyMemberData member, string key)
// or
public readonly string GetMemberMetadata(string key)
// or
public readonly string GetMemberMetadata(UserData memberId, string key)
```

Reads the metadata of a given user from the lobby. If no member is indicated it will assume the local user.

***

### Get Metadata

```csharp
public readonly Dictionary<string, string> GetMetadata()
```

Gets a dictionary containing all the lobby's metadata.

***

### Invite User to Lobby

```csharp
public readonly bool InviteUserToLobby(UserData targetUser)
```

Invite the indicated user to the lobby

***

### Is a Member

```csharp
public readonly bool IsAMember(UserData id)
```

Checks if a user is a member of this lobby.

***

### Join

<pre class="language-csharp"><code class="lang-csharp"><strong>public readonly void Join(AccountID_t accountId, Action&#x3C;LobbyEnter, bool> callback)
</strong>// or
public readonly void Join(Action&#x3C;LobbyEnter, bool> callback)
// or
public static void Join(LobbyData lobby, Action&#x3C;LobbyEnter, bool> callback)
// or
public static void Join(string accountId, Action&#x3C;LobbyEnter, bool> callback)
</code></pre>

Joins the indicated lobby; in all cases, the callback has the same form.

```csharp
void Callback(LobbyEnter Data, bool IOError)
{
    // Data.Lobby is the lobby you joined
    // Data.Response is the chat room response when you joined
    // Data.Locked if this lobby is locked
}
```

***

### Kick List Contains

```csharp
public readonly bool KickListContains(UserData memberId)
```

Check if the indicated user is contained in the list of members who should leave the lobby

***

### Kick Member

```csharp
public readonly bool KickMember(UserData memberId)
```

Marks the user to be removed.

***

### Leave

```csharp
public readonly void Leave()
```

Leaves the current lobby if any.

***

### Party Lobby

```csharp
public static bool GroupLobby(out LobbyData lobby)
```

Returns the first lobby the user is a member of where lobby.IsGroup was set to true

***

### Quick Match

```csharp
public static void QuickMatch(SearchArguments searchArguments, CreateArguments createArguments, Action<EResult, LobbyData, bool> callback)
```

Using the Search Arguments, it will search for a matching lobby. If one is found, it will join it; if not, and if the createOnFail parameter is true, it will create a lobby according to the Create Arguments.

***

### Remove from Kick List

```csharp
public readonly bool RemoveFromKickList(UserData memberId)
```

Removes the indicated member from the kick list

***

### Request

```csharp
public static void Request(ELobbyDistanceFilter distanceFilter, int openSlotsRequired, int maxResultsToReturn, IEnumerable<StringFilter> stringFilters, IEnumerable<NearFilter> nearFilters, IEnumerable<NumericFilter> numericFilters, Action<LobbyData[], bool> callback)
// or 
public static void Request(SearchArguments searchArguments, int maxResultsToReturn, Action<LobbyData[], bool> callback)
```

Request a list of lobbies that match the input filters.

***

### Request Data

```csharp
public readonly bool RequestData()
```

Refreshes all of the metadata for a lobby that you're not in right now. You will never do this for lobbies you're a member of, that data will always be up to date. You can use this to refresh lobbies that you have obtained from RequestLobbyList or that are available via friends.

***

### Send Chat Message

```csharp
public bool SendChatMessage(string message)
// or
public bool SendChatMessage(byte[] data)
// or 
public bool SendChatMessage(object jsonObject)
```

Send a Steam Lobby Chat message to the lobby. You can send a string, a byte\[] of binary data or you can provide a JSON Serializable object and we will serialize that and send it as an object.

***

### Session Lobby

```csharp
public static bool SessionLobby(out LobbyData lobby)
```

Returns the first lobby where lobby.IsSession was set to true.

***

### Set Game Server

```csharp
public readonly void SetGameServer()
// or
public readonly void SetGameServer(CSteamID gameServerId)
// or
public readonly void SetGameServer(string address, ushort port, CSteamID gameServerId)
// or 
public readonly void SetGameServer(string address, ushort port)
```

Sets the game server associated with the lobby. You can indicate a Steam ID and or an IP:Port. If you do not provide any parameters, it will assume the owner of the Lobby is the server, e.g. is the Host.

***

### Set Joinable

```csharp
public readonly bool SetJoinable(bool makeJoinable)
```

Mark the lobby as joinable or not.

***

### Set Member Metadata

```csharp
public readonly void SetMemberMetadata(string key, string value)
```

Set the metadata for the player on the lobby.

***

### Set Type

```csharp
public readonly bool SetType(ELobbyType type)
```

Updates the lobby type, can only be called by the owner of the lobby.
