Struct SteamNetworkingIdentity
The identity of a network host: a SteamID, IP address, generic string or bytes, and so on. Every identity has a string form (see ToString()), which is what goes on the wire in several places, so older code can carry identity types it does not understand. The payload is not exposed as fields: read and write it through the methods.
Implements
Inherited Members
Namespace: Unity.Steamworks.Interop
Assembly: Unity.Steamworks.Interop.dll
Syntax
[Serializable]
public struct SteamNetworkingIdentity : IEquatable<SteamNetworkingIdentity>
Fields
k_cbMaxGenericBytes
Maximum length, in bytes, of a generic bytes identity.
Declaration
public const int k_cbMaxGenericBytes = 32
Field Value
| Type | Description |
|---|---|
| int |
k_cchMaxGenericString
Maximum length of a generic string identity, including the terminator.
Declaration
public const int k_cchMaxGenericString = 32
Field Value
| Type | Description |
|---|---|
| int |
k_cchMaxString
Buffer size, including the terminator, that fits any ToString() output.
Declaration
public const int k_cchMaxString = 128
Field Value
| Type | Description |
|---|---|
| int |
k_cchMaxXboxPairwiseID
Maximum length of an Xbox pairwise id, including the terminator.
Declaration
public const int k_cchMaxXboxPairwiseID = 33
Field Value
| Type | Description |
|---|---|
| int |
m_eType
Which kind of identity this is.
Declaration
public ESteamNetworkingIdentityType m_eType
Field Value
| Type | Description |
|---|---|
| ESteamNetworkingIdentityType |
Methods
Clear()
Resets this identity to the invalid state.
Declaration
public void Clear()
Equals(SteamNetworkingIdentity)
Compares this identity with another.
Declaration
public bool Equals(SteamNetworkingIdentity other)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamNetworkingIdentity | other | The identity to compare with. |
Returns
| Type | Description |
|---|---|
| bool | true when both have the same type and payload. |
GetFakeIPType()
Classifies the carried IP address as a kind of FakeIP, or as not fake.
Declaration
public ESteamNetworkingFakeIPType GetFakeIPType()
Returns
| Type | Description |
|---|---|
| ESteamNetworkingFakeIPType | The address's FakeIP type, or k_ESteamNetworkingFakeIPType_Invalid when the identity is not an IP address. |
GetGenericBytes()
Gets the generic bytes this identity carries.
Declaration
public byte[] GetGenericBytes()
Returns
| Type | Description |
|---|---|
| byte[] | A copy of the bytes, or null when the identity is not generic bytes. |
GetGenericString()
Gets the generic string this identity carries.
Declaration
public string GetGenericString()
Returns
| Type | Description |
|---|---|
| string | The string, or null when the identity is not a generic string. |
GetIPAddr(out SteamNetworkingIPAddr)
Gets the IP address and port this identity carries.
Declaration
public bool GetIPAddr(out SteamNetworkingIPAddr addr)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamNetworkingIPAddr | addr | Receives a copy of the address, or default when there is none. |
Returns
| Type | Description |
|---|---|
| bool | false when the identity is not an IP address. |
GetIPv4()
Gets the IPv4 address this identity carries, in host byte order.
Declaration
public uint GetIPv4()
Returns
| Type | Description |
|---|---|
| uint | The address, or 0 when the identity is not an IPv4 address. |
GetPSNID()
Gets the PSN account id this identity carries.
Declaration
public ulong GetPSNID()
Returns
| Type | Description |
|---|---|
| ulong | The id, or 0 when the identity is not a PSN id. |
GetSteamID()
Gets the SteamID this identity carries.
Declaration
public CSteamID GetSteamID()
Returns
| Type | Description |
|---|---|
| CSteamID | The SteamID, or an invalid CSteamID when the identity is not a SteamID. |
GetSteamID64()
Gets the SteamID this identity carries, as a raw 64-bit number.
Declaration
public ulong GetSteamID64()
Returns
| Type | Description |
|---|---|
| ulong | The SteamID, or 0 when the identity is not a SteamID. |
GetXboxPairwiseID()
Gets the Xbox pairwise id this identity carries.
Declaration
public string GetXboxPairwiseID()
Returns
| Type | Description |
|---|---|
| string | The id, or null when the identity is not an Xbox pairwise id. |
IsFakeIP()
Checks whether this identity is a FakeIP address.
Declaration
public bool IsFakeIP()
Returns
| Type | Description |
|---|---|
| bool | true when GetFakeIPType() reports a FakeIP type. |
IsInvalid()
Checks whether the identity type is Invalid. The payload is not validated (for example, whether a SteamID is valid).
Declaration
public bool IsInvalid()
Returns
| Type | Description |
|---|---|
| bool | true when the type is k_ESteamNetworkingIdentityType_Invalid. |
IsLocalHost()
Checks whether this identity is localhost.
Declaration
public bool IsLocalHost()
Returns
| Type | Description |
|---|---|
| bool | true for ::1 or 127.0.0.1. |
ParseString(string)
Parses the string form ToString() produces. A well-formed string of an unknown type still succeeds, as k_ESteamNetworkingIdentityType_UnknownType.
Declaration
public bool ParseString(string pszStr)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pszStr | The string to parse. |
Returns
| Type | Description |
|---|---|
| bool | false only when the string is malformed. |
SetGenericBytes(byte[])
Sets this identity to generic bytes.
Declaration
public bool SetGenericBytes(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The bytes; at most k_cbMaxGenericBytes of them. |
Returns
| Type | Description |
|---|---|
| bool | false when the data has an invalid size. |
SetGenericString(string)
Sets this identity to a generic string.
Declaration
public bool SetGenericString(string pszString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pszString | The string; at most k_cchMaxGenericString bytes including the terminator. |
Returns
| Type | Description |
|---|---|
| bool | false when the string has an invalid length. |
SetIPAddr(SteamNetworkingIPAddr)
Sets this identity to an IP address and port.
Declaration
public void SetIPAddr(SteamNetworkingIPAddr addr)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamNetworkingIPAddr | addr | The address to carry. |
SetIPv4Addr(uint, ushort)
Sets this identity to an IPv4 address and port.
Declaration
public void SetIPv4Addr(uint nIPv4, ushort nPort)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | nIPv4 | The address in host byte order: aa.bb.cc.dd as 0xaabbccdd. |
| ushort | nPort | The port, in host byte order. |
SetLocalHost()
Sets this identity to localhost, always IPv6 ::1 rather than 127.0.0.1. Localhost often stands for "anonymous": the remote host identifies the local host by its network address.
Declaration
public void SetLocalHost()
SetPSNID(ulong)
Sets this identity to a PlayStation Network account.
Declaration
public void SetPSNID(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | id | The PSN account id. |
SetSteamID(CSteamID)
Sets this identity to a Steam account.
Declaration
public void SetSteamID(CSteamID steamID)
Parameters
| Type | Name | Description |
|---|---|---|
| CSteamID | steamID | The account's SteamID. |
SetSteamID64(ulong)
Sets this identity to a Steam account given as a raw 64-bit SteamID.
Declaration
public void SetSteamID64(ulong steamID)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | steamID | The 64-bit SteamID. |
SetXboxPairwiseID(string)
Sets this identity to an Xbox pairwise id.
Declaration
public bool SetXboxPairwiseID(string pszString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pszString | The id; at most k_cchMaxXboxPairwiseID bytes including the terminator. |
Returns
| Type | Description |
|---|---|
| bool | false when the string has an invalid length. |
ToString()
Formats the identity in its URL-like string form, type:<type-data>, which ParseString(string) reads back.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The formatted identity. |