using System; using System.Runtime.InteropServices; namespace Facepunch.Steamworks { public partial class Client : BaseSteamworks { /// /// Current user's Username /// public string Username { get; private set; } /// /// Current user's SteamId /// public ulong SteamId { get; private set; } /// /// Current Beta name, if ser /// public string BetaName { get; private set; } public Voice Voice { get; internal set; } public Client( uint appId ) { native = new Interop.NativeInterface(); // // Get other interfaces // if ( !native.InitClient() ) { native.Dispose(); native = null; return; } // // Set up warning hook callback // // SteamAPIWarningMessageHook ptr = InternalOnWarning; // native.client.SetWarningMessageHook( Marshal.GetFunctionPointerForDelegate( ptr ) ); // // Setup interfaces that client and server both have // SetupCommonInterfaces(); // // Client only interfaces // Voice = new Voice( this ); Workshop.friends = Friends; // // Cache common, unchanging info // AppId = appId; Username = native.friends.GetPersonaName(); SteamId = native.user.GetSteamID(); BetaName = native.apps.GetCurrentBetaName(); // // Run update, first call does some initialization // Update(); } [UnmanagedFunctionPointer( CallingConvention.Cdecl )] public delegate void SteamAPIWarningMessageHook( int nSeverity, System.Text.StringBuilder pchDebugText ); private void InternalOnWarning( int nSeverity, System.Text.StringBuilder text ) { if ( OnMessage != null ) { OnMessage( ( MessageType)nSeverity, text.ToString() ); } } /// /// Should be called at least once every frame /// public override void Update() { if ( !IsValid ) return; native.api.SteamAPI_RunCallbacks(); Voice.Update(); base.Update(); native.api.SteamAPI_RunCallbacks(); } public override void Dispose() { if ( Voice != null ) { Voice.Dispose(); Voice = null; } base.Dispose(); } } }