using System.Threading.Tasks; using Facepunch.Steamworks.Data; namespace Facepunch.Steamworks { public struct PartyBeacon { static ISteamParties Internal => SteamParties.Internal; internal PartyBeaconID_t Id; /// /// Creator of the beacon /// public SteamId Owner { get { var owner = default( SteamId ); var location = default( SteamPartyBeaconLocation_t ); Internal.GetBeaconDetails( Id, ref owner, ref location, out _ ); return owner; } } /// /// Creator of the beacon /// public string MetaData { get { var owner = default( SteamId ); var location = default( SteamPartyBeaconLocation_t ); _ = Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal ); return strVal; } } /// /// Will attempt to join the party. If successful will return a connection string. /// If failed, will return null /// public async Task JoinAsync() { var result = await Internal.JoinParty( Id ); if ( !result.HasValue || result.Value.Result != Result.OK ) return null; return result.Value.ConnectStringUTF8(); } /// /// When a user follows your beacon, Steam will reserve one of the open party slots for them, and send your game a ReservationNotification callback. /// When that user joins your party, call OnReservationCompleted to notify Steam that the user has joined successfully /// public void OnReservationCompleted( SteamId steamid ) { Internal.OnReservationCompleted( Id, steamid ); } /// /// To cancel a reservation (due to timeout or user input), call this. /// Steam will open a new reservation slot. /// Note: The user may already be in-flight to your game, so it's possible they will still connect and try to join your party. /// public void CancelReservation( SteamId steamid ) { Internal.CancelReservation( Id, steamid ); } /// /// Turn off the beacon /// public bool Destroy() { return Internal.DestroyBeacon( Id ); } } }