mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
SteamId
This commit is contained in:
parent
cb85e41c52
commit
f39341d90f
4
.gitignore
vendored
4
.gitignore
vendored
@ -59,4 +59,6 @@ TestResults
|
||||
obj
|
||||
Facepunch.Steamworks/bin/Debug/Facepunch.Steamworks.Api.dll
|
||||
Facepunch.Steamworks/bin/Debug/Facepunch.Steamworks.dll
|
||||
Facepunch.Steamworks/bin/Release/Facepunch.Steamworks.dll
|
||||
Facepunch.Steamworks/bin/Release/Facepunch.Steamworks.dll
|
||||
*.opendb
|
||||
*.db
|
@ -25,6 +25,19 @@ public void ClientName()
|
||||
var username = client.Username;
|
||||
Console.WriteLine( username );
|
||||
Assert.IsTrue( client.Valid );
|
||||
Assert.IsNotNull( username );
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClientSteamId()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
{
|
||||
var steamid = client.SteamId;
|
||||
Console.WriteLine( steamid );
|
||||
Assert.IsTrue( client.Valid );
|
||||
Assert.AreNotEqual( 0, steamid );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facepunch.Steamworks
|
||||
{
|
||||
@ -22,6 +23,11 @@ public class Client : IDisposable
|
||||
/// </summary>
|
||||
public string Username { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current user's SteamId
|
||||
/// </summary>
|
||||
public ulong SteamId;
|
||||
|
||||
public Client( int appId )
|
||||
{
|
||||
Valve.Steamworks.SteamAPI.Init( (uint) appId );
|
||||
@ -33,15 +39,28 @@ public Client( int appId )
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Set up warning hook callback
|
||||
//
|
||||
SteamAPIWarningMessageHook ptr = OnWarning;
|
||||
_client.SetWarningMessageHook( Marshal.GetFunctionPointerForDelegate( ptr ) );
|
||||
|
||||
//
|
||||
// Get pipes
|
||||
//
|
||||
_hpipe = _client.CreateSteamPipe();
|
||||
_huser = _client.ConnectToGlobalUser( _hpipe );
|
||||
|
||||
|
||||
//
|
||||
// Get other interfaces
|
||||
//
|
||||
_friends = _client.GetISteamFriends( _huser, _hpipe, "SteamFriends015" );
|
||||
// _user = Valve.Steamworks.SteamAPI.SteamUser();
|
||||
_user = _client.GetISteamUser( _huser, _hpipe, "SteamUser019" );
|
||||
|
||||
AppId = appId;
|
||||
Username = _friends.GetPersonaName();
|
||||
SteamId = _user.GetSteamID();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -66,6 +85,14 @@ public void Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate void SteamAPIWarningMessageHook( int nSeverity, System.Text.StringBuilder pchDebugText );
|
||||
|
||||
private void OnWarning( int nSeverity, System.Text.StringBuilder text )
|
||||
{
|
||||
Console.Write( text.ToString() );
|
||||
}
|
||||
|
||||
public bool Valid
|
||||
{
|
||||
get { return _client != null; }
|
||||
|
@ -2410,7 +2410,7 @@ internal override ISteamUser GetISteamUser( uint hSteamUser, uint hSteamPipe, st
|
||||
{
|
||||
CheckIfUsable();
|
||||
IntPtr result = NativeEntrypoints.SteamAPI_ISteamClient_GetISteamUser(m_pSteamClient,hSteamUser,hSteamPipe,pchVersion);
|
||||
return (ISteamUser)Marshal.PtrToStructure( result, typeof( ISteamUser ) );
|
||||
return new CSteamUser( result );
|
||||
}
|
||||
internal override ISteamGameServer GetISteamGameServer( uint hSteamUser, uint hSteamPipe, string pchVersion )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user