Class SteamMemberData
- Namespace
- SteamNetworkLib.Core
- Assembly
- SteamNetworkLib.dll
Manages Steam lobby member data (per-player key-value storage). Provides functionality for setting, getting, and managing player-specific data that is visible to all lobby members.
public class SteamMemberData : IDisposable
- Inheritance
-
SteamMemberData
- Implements
- Inherited Members
Constructors
SteamMemberData(SteamLobbyManager)
Initializes a new instance of the SteamMemberData class.
public SteamMemberData(SteamLobbyManager lobbyManager)
Parameters
lobbyManager
SteamLobbyManagerThe lobby manager instance to use for lobby operations.
Exceptions
- ArgumentNullException
Thrown when lobbyManager is null.
Methods
Dispose()
Releases all resources used by the SteamMemberData.
public void Dispose()
GetAllMemberData(CSteamID)
Gets all data for a specific player.
public Dictionary<string, string> GetAllMemberData(CSteamID playerId)
Parameters
playerId
CSteamIDThe Steam ID of the player whose data to retrieve.
Returns
- Dictionary<string, string>
A dictionary containing all key-value pairs for the specified player, or an empty dictionary if not in a lobby.
GetAllMemberDataSummary()
Gets a summary of all member data across all players in the lobby.
public Dictionary<CSteamID, Dictionary<string, string>> GetAllMemberDataSummary()
Returns
- Dictionary<CSteamID, Dictionary<string, string>>
A dictionary mapping player Steam IDs to their complete data dictionaries. Useful for debugging and overview purposes.
GetMemberData(CSteamID, string)
Gets data for a specific player.
public string? GetMemberData(CSteamID playerId, string key)
Parameters
playerId
CSteamIDThe Steam ID of the player whose data to retrieve.
key
stringThe data key to retrieve.
Returns
- string
The data value if found, or null if not found or not in a lobby.
Exceptions
- ArgumentException
Thrown when the key is invalid.
GetMemberData(string)
Gets data for the local player.
public string? GetMemberData(string key)
Parameters
key
stringThe data key to retrieve.
Returns
- string
The data value if found, or null if not found or not in a lobby.
GetMemberDataForAllPlayers(string)
Gets the same data key for all players in the lobby.
public Dictionary<CSteamID, string> GetMemberDataForAllPlayers(string key)
Parameters
key
stringThe data key to retrieve for all players.
Returns
- Dictionary<CSteamID, string>
A dictionary mapping player Steam IDs to their data values for the specified key.
Exceptions
- ArgumentException
Thrown when the key is invalid.
GetPlayersWithData(string)
Gets a list of players who have data for the specified key.
public List<CSteamID> GetPlayersWithData(string key)
Parameters
key
stringThe data key to check.
Returns
- List<CSteamID>
A list of Steam IDs for players who have data for the specified key.
Exceptions
- ArgumentException
Thrown when the key is invalid.
HasMemberData(CSteamID, string)
Checks whether a specific player has data for the specified key.
public bool HasMemberData(CSteamID playerId, string key)
Parameters
playerId
CSteamIDThe Steam ID of the player to check.
key
stringThe data key to check.
Returns
- bool
True if the key exists and has a non-empty value, false otherwise.
HasMemberData(string)
Checks whether the local player has data for the specified key.
public bool HasMemberData(string key)
Parameters
key
stringThe data key to check.
Returns
- bool
True if the key exists and has a non-empty value, false otherwise.
RefreshAllMemberData()
Refreshes the member data cache for all players by reloading from Steam servers.
public void RefreshAllMemberData()
RefreshMemberData(CSteamID)
Refreshes the member data cache for a specific player by reloading from Steam servers.
public void RefreshMemberData(CSteamID playerId)
Parameters
playerId
CSteamIDThe Steam ID of the player whose data to refresh.
RemoveMemberData(string)
Removes data for the local player.
public void RemoveMemberData(string key)
Parameters
key
stringThe data key to remove.
Exceptions
- ArgumentException
Thrown when the key is invalid.
- LobbyException
Thrown when not in a lobby.
SetMemberData(CSteamID, string, string)
Sets data for a specific player. Only the local player can set their own data.
public void SetMemberData(CSteamID playerId, string key, string value)
Parameters
playerId
CSteamIDThe Steam ID of the player. Must be the local player.
key
stringThe data key. Cannot be null, empty, or exceed 255 characters.
value
stringThe data value to set.
Exceptions
- ArgumentException
Thrown when the key is invalid.
- LobbyException
Thrown when not in a lobby or trying to set data for another player.
SetMemberData(string, string)
Sets data for the local player.
public void SetMemberData(string key, string value)
Parameters
key
stringThe data key. Cannot be null, empty, or exceed 255 characters.
value
stringThe data value to set.
Exceptions
- ArgumentException
Thrown when the key is invalid.
- LobbyException
Thrown when not in a lobby.
SetMemberDataBatch(Dictionary<string, string>)
Sets multiple data values for the local player in a batch operation.
public void SetMemberDataBatch(Dictionary<string, string> data)
Parameters
data
Dictionary<string, string>A dictionary containing key-value pairs to set. Null or empty dictionaries are ignored.
Exceptions
- LobbyException
Thrown when not in a lobby or any individual set operation fails.
Events
OnMemberDataChanged
Occurs when member data is changed for any player in the lobby.
public event EventHandler<MemberDataChangedEventArgs>? OnMemberDataChanged