Pull req - OnLobbyEntered Action and JoinLobbyAsync

Added an OnLobbyEntered action with associated LobbyEnter_t event install, and added a JoinLobbyAsync method which returns the joined lobby if successful
This commit is contained in:
thesupersoup 2019-06-19 21:14:35 -07:00
parent 1c5cdd2d39
commit cb06574820

View File

@ -37,6 +37,8 @@ internal static void InstallEvents()
{
LobbyInvite_t.Install( x => OnLobbyInvite?.Invoke( new Friend( x.SteamIDUser ), new Lobby( x.SteamIDLobby ) ) );
LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby(x.SteamIDLobby ) ) );
LobbyDataUpdate_t.Install( x =>
{
if ( x.Success == 0 ) return;
@ -90,6 +92,11 @@ static private unsafe void OnLobbyChatMessageRecievedAPI( LobbyChatMsg_t callbac
/// </summary>
public static event Action<Friend, Lobby> OnLobbyInvite;
/// <summary>
/// You joined a lobby
/// </summary>
public static event Action<Lobby> OnLobbyEntered;
/// <summary>
/// The lobby metadata has changed
/// </summary>
@ -143,6 +150,17 @@ static private unsafe void OnLobbyChatMessageRecievedAPI( LobbyChatMsg_t callbac
return new Lobby { Id = lobby.Value.SteamIDLobby };
}
/// <summmary>
/// Attempts to directly join the specified lobby
/// </summmary>
public static async Task<Lobby?> JoinLobbyAsync( SteamId lobbyId )
{
var lobby = await Internal.JoinLobby( lobbyId );
if ( !lobby.HasValue ) return null;
return new Lobby { Id = lobby.Value.SteamIDLobby };
}
/// <summary>
/// Get a list of servers that are on your favorites list
/// </summary>