diff options
Diffstat (limited to 'Assembly_Firstpass/Steamworks/SteamNetworkingIdentity.cs')
-rw-r--r-- | Assembly_Firstpass/Steamworks/SteamNetworkingIdentity.cs | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Assembly_Firstpass/Steamworks/SteamNetworkingIdentity.cs b/Assembly_Firstpass/Steamworks/SteamNetworkingIdentity.cs new file mode 100644 index 0000000..057391c --- /dev/null +++ b/Assembly_Firstpass/Steamworks/SteamNetworkingIdentity.cs @@ -0,0 +1,112 @@ +using System; +using System.Runtime.InteropServices; + +namespace Steamworks; + +[Serializable] +[StructLayout(LayoutKind.Sequential, Pack = 1)] +public struct SteamNetworkingIdentity : IEquatable<SteamNetworkingIdentity> +{ + public ESteamNetworkingIdentityType m_eType; + + private int m_cbSize; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + private uint[] m_reserved; + + public const int k_cchMaxString = 128; + + public const int k_cchMaxGenericString = 32; + + public const int k_cbMaxGenericBytes = 32; + + public void Clear() + { + NativeMethods.SteamAPI_SteamNetworkingIdentity_Clear(ref this); + } + + public bool IsInvalid() + { + return NativeMethods.SteamAPI_SteamNetworkingIdentity_IsInvalid(ref this); + } + + public void SetSteamID(CSteamID steamID) + { + NativeMethods.SteamAPI_SteamNetworkingIdentity_SetSteamID(ref this, (ulong)steamID); + } + + public CSteamID GetSteamID() + { + return (CSteamID)NativeMethods.SteamAPI_SteamNetworkingIdentity_GetSteamID(ref this); + } + + public void SetSteamID64(ulong steamID) + { + NativeMethods.SteamAPI_SteamNetworkingIdentity_SetSteamID64(ref this, steamID); + } + + public ulong GetSteamID64() + { + return NativeMethods.SteamAPI_SteamNetworkingIdentity_GetSteamID64(ref this); + } + + public void SetIPAddr(SteamNetworkingIPAddr addr) + { + NativeMethods.SteamAPI_SteamNetworkingIdentity_SetIPAddr(ref this, ref addr); + } + + public SteamNetworkingIPAddr GetIPAddr() + { + throw new NotImplementedException(); + } + + public void SetLocalHost() + { + NativeMethods.SteamAPI_SteamNetworkingIdentity_SetLocalHost(ref this); + } + + public bool IsLocalHost() + { + return NativeMethods.SteamAPI_SteamNetworkingIdentity_IsLocalHost(ref this); + } + + public bool SetGenericString(string pszString) + { + using InteropHelp.UTF8StringHandle pszString2 = new InteropHelp.UTF8StringHandle(pszString); + return NativeMethods.SteamAPI_SteamNetworkingIdentity_SetGenericString(ref this, pszString2); + } + + public string GetGenericString() + { + return InteropHelp.PtrToStringUTF8(NativeMethods.SteamAPI_SteamNetworkingIdentity_GetGenericString(ref this)); + } + + public bool SetGenericBytes(byte[] data, uint cbLen) + { + return NativeMethods.SteamAPI_SteamNetworkingIdentity_SetGenericBytes(ref this, data, cbLen); + } + + public byte[] GetGenericBytes(out int cbLen) + { + throw new NotImplementedException(); + } + + public bool Equals(SteamNetworkingIdentity x) + { + return NativeMethods.SteamAPI_SteamNetworkingIdentity_IsEqualTo(ref this, ref x); + } + + public void ToString(out string buf) + { + IntPtr intPtr = Marshal.AllocHGlobal(128); + NativeMethods.SteamNetworkingIdentity_ToString(ref this, intPtr, 128u); + buf = InteropHelp.PtrToStringUTF8(intPtr); + Marshal.FreeHGlobal(intPtr); + } + + public bool ParseString(string pszStr) + { + using InteropHelp.UTF8StringHandle pszStr2 = new InteropHelp.UTF8StringHandle(pszStr); + return NativeMethods.SteamNetworkingIdentity_ParseString(ref this, pszStr2); + } +} |