Class ISteamNetworkingSockets
- Namespace
- MarymoorStudios.Core.Steamworks
- Assembly
- MarymoorStudios.Core.Steamworks.dll
public sealed class ISteamNetworkingSockets : SteamNativeObject
- Inheritance
-
ISteamNetworkingSockets
- Inherited Members
Fields
INTERFACE_VERSION
public const string INTERFACE_VERSION = "SteamNetworkingSockets012"
Field Value
Methods
AcceptConnection(HSteamNetConnection)
public EResult AcceptConnection(HSteamNetConnection conn)
Parameters
conn
HSteamNetConnection
Returns
BeginAsyncRequestFakeIP(int)
public bool BeginAsyncRequestFakeIP(int numPorts)
Parameters
numPorts
int
Returns
CloseConnection(HSteamNetConnection, int, string?, bool)
public bool CloseConnection(HSteamNetConnection peer, int reason = 0, string? pszDebug = null, bool enableLinger = false)
Parameters
peer
HSteamNetConnectionreason
intpszDebug
stringenableLinger
bool
Returns
CloseListenSocket(HSteamListenSocket)
public bool CloseListenSocket(HSteamListenSocket socket)
Parameters
socket
HSteamListenSocket
Returns
ConfigureConnectionLanes(HSteamNetConnection, ReadOnlySpan<int>, ReadOnlySpan<ushort>)
public EResult ConfigureConnectionLanes(HSteamNetConnection conn, ReadOnlySpan<int> lanePriorities, ReadOnlySpan<ushort> laneWeights)
Parameters
conn
HSteamNetConnectionlanePriorities
ReadOnlySpan<int>laneWeights
ReadOnlySpan<ushort>
Returns
ConnectByIPAddress(in SteamNetworkingIPAddr, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamNetConnection ConnectByIPAddress(in SteamNetworkingIPAddr address, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
address
SteamNetworkingIPAddroptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
ConnectP2P(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>)
Connecting to a peer by id (instead of IP address).
public HSteamNetConnection ConnectP2P(in SteamNetworkingIdentity identityRemote, int remoteVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
identityRemote
SteamNetworkingIdentityThe identity of the peer to connect to.
remoteVirtualPort
intThe port to connect on (usually 0).
options
ReadOnlySpan<SteamNetworkingConfigValue>Connection options.
Returns
- HSteamNetConnection
The connection handle if successful, otherwise Invalid.
Remarks
Begin connecting to a peer that is identified using a platform-specific identifier. This uses the default rendezvous service, which depends on the platform and library configuration. (E.g. on Steam, it goes through the steam backend.) The traffic is relayed over the Steam Datagram Relay network. If you use this, you probably want to call InitRelayNetworkAccess() when your app initializes. If you need to set any initial config options, pass them here. See SteamNetworkingConfigValue for more about why this is preferable to setting the options "immediately" after creation.
ConnectP2PCustomSignaling(ref ISteamNetworkingConnectionSignaling, in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamNetConnection ConnectP2PCustomSignaling(ref ISteamNetworkingConnectionSignaling signaling, in SteamNetworkingIdentity peerIdentity, int remoteVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
signaling
ISteamNetworkingConnectionSignalingpeerIdentity
SteamNetworkingIdentityremoteVirtualPort
intoptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
ConnectToHostedDedicatedServer(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamNetConnection ConnectToHostedDedicatedServer(in SteamNetworkingIdentity identityTarget, int remoteVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
identityTarget
SteamNetworkingIdentityremoteVirtualPort
intoptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateFakeUDPPort(int)
public ISteamNetworkingFakeUDPPort CreateFakeUDPPort(int idxFakeServerPort)
Parameters
idxFakeServerPort
int
Returns
CreateHostedDedicatedServerListenSocket(int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamListenSocket CreateHostedDedicatedServerListenSocket(int localVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localVirtualPort
intoptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateListenSocketIP(in SteamNetworkingIPAddr, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamListenSocket CreateListenSocketIP(in SteamNetworkingIPAddr localAddress, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localAddress
SteamNetworkingIPAddroptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateListenSocketP2P(int, ReadOnlySpan<SteamNetworkingConfigValue>)
Listen for connection by CSteamID through the Valve network.
public HSteamListenSocket CreateListenSocketP2P(int localVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localVirtualPort
intThe port to use in ConnectP2P(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>) .
options
ReadOnlySpan<SteamNetworkingConfigValue>Socket options.
Returns
- HSteamListenSocket
The socket handle if successful, otherwise Invalid.
Remarks
Like CreateListenSocketIP(in SteamNetworkingIPAddr, ReadOnlySpan<SteamNetworkingConfigValue>) , but clients will connect using ConnectP2P(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>) . The connection will be relayed through the Valve network.
localVirtualPort
specifies how clients can connect to this socket using
ConnectP2P(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>)
. It's very common for applications to only have one listening socket; in that case, use zero. If you need to
open multiple listen sockets and have clients be able to connect to one or the other, then
localVirtualPort
should be a small integer (<1000) unique to each listen socket you
create.
If you are listening on a dedicated servers in known data center, then you can listen using this function instead of CreateHostedDedicatedServerListenSocket(int, ReadOnlySpan<SteamNetworkingConfigValue>) , to allow clients to connect without a ticket. Any user that owns the app and is signed in to Steam will be able to attempt to connect to your server. Also, a connection attempt may require the client to be connected to Steam, which is one more moving part that may fail. When tickets are used, then once a ticket is obtained, a client can connect to your server even if they got disconnected from Steam or Steam is offline.
If you use this, you probably want to call InitRelayNetworkAccess() when your app initializes.
If you need to set any initial config options, pass them here. See SteamNetworkingConfigValue for more about why this is preferable to setting the options "immediately" after creation.
CreateListenSocketP2PFakeIP(int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamListenSocket CreateListenSocketP2PFakeIP(int idxFakePort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
idxFakePort
intoptions
ReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreatePollGroup()
public HSteamNetPollGroup CreatePollGroup()
Returns
CreateSocketPair(out HSteamNetConnection, out HSteamNetConnection, bool, in SteamNetworkingIdentity, in SteamNetworkingIdentity)
public bool CreateSocketPair(out HSteamNetConnection outConnection1, out HSteamNetConnection outConnection2, bool useNetworkLoopback, in SteamNetworkingIdentity identity1, in SteamNetworkingIdentity identity2)
Parameters
outConnection1
HSteamNetConnectionoutConnection2
HSteamNetConnectionuseNetworkLoopback
boolidentity1
SteamNetworkingIdentityidentity2
SteamNetworkingIdentity
Returns
DestroyPollGroup(HSteamNetPollGroup)
public bool DestroyPollGroup(HSteamNetPollGroup pollGroup)
Parameters
pollGroup
HSteamNetPollGroup
Returns
FindRelayAuthTicketForServer(in SteamNetworkingIdentity, int, out SteamDatagramRelayAuthTicket)
public int FindRelayAuthTicketForServer(in SteamNetworkingIdentity identityGameServer, int remoteVirtualPort, out SteamDatagramRelayAuthTicket outParsedTicket)
Parameters
identityGameServer
SteamNetworkingIdentityremoteVirtualPort
intoutParsedTicket
SteamDatagramRelayAuthTicket
Returns
FlushMessagesOnConnection(HSteamNetConnection)
public EResult FlushMessagesOnConnection(HSteamNetConnection conn)
Parameters
conn
HSteamNetConnection
Returns
GetAuthenticationStatus(out SteamNetAuthenticationStatus)
public ESteamNetworkingAvailability GetAuthenticationStatus(out SteamNetAuthenticationStatus details)
Parameters
details
SteamNetAuthenticationStatus
Returns
GetCertificateRequest(out int, Span<byte>, out string)
public bool GetCertificateRequest(out int blobCount, Span<byte> blob, out string errMsg)
Parameters
Returns
GetConnectionInfo(HSteamNetConnection, out SteamNetConnectionInfo)
public bool GetConnectionInfo(HSteamNetConnection conn, out SteamNetConnectionInfo info)
Parameters
conn
HSteamNetConnectioninfo
SteamNetConnectionInfo
Returns
GetConnectionName(HSteamNetConnection, Span<byte>)
public bool GetConnectionName(HSteamNetConnection peer, Span<byte> pszName)
Parameters
peer
HSteamNetConnectionpszName
Span<byte>
Returns
GetConnectionRealTimeStatus(HSteamNetConnection, out SteamNetConnectionRealTimeStatus, Span<SteamNetConnectionRealTimeLaneStatus>)
public EResult GetConnectionRealTimeStatus(HSteamNetConnection conn, out SteamNetConnectionRealTimeStatus status, Span<SteamNetConnectionRealTimeLaneStatus> lanes)
Parameters
conn
HSteamNetConnectionstatus
SteamNetConnectionRealTimeStatuslanes
Span<SteamNetConnectionRealTimeLaneStatus>
Returns
GetConnectionUserData(HSteamNetConnection)
public long GetConnectionUserData(HSteamNetConnection peer)
Parameters
peer
HSteamNetConnection
Returns
GetDetailedConnectionStatus(HSteamNetConnection, Span<byte>)
public int GetDetailedConnectionStatus(HSteamNetConnection conn, Span<byte> pszBuf)
Parameters
conn
HSteamNetConnectionpszBuf
Span<byte>
Returns
GetFakeIP(int, out SteamNetworkingFakeIPResult)
public void GetFakeIP(int idxFirstPort, out SteamNetworkingFakeIPResult info)
Parameters
idxFirstPort
intinfo
SteamNetworkingFakeIPResult
GetGameCoordinatorServerLogin(ref SteamDatagramGameCoordinatorServerLogin, out int, Span<byte>)
public EResult GetGameCoordinatorServerLogin(ref SteamDatagramGameCoordinatorServerLogin loginInfo, out int signedBlobCount, Span<byte> blob)
Parameters
loginInfo
SteamDatagramGameCoordinatorServerLoginsignedBlobCount
intblob
Span<byte>
Returns
GetHostedDedicatedServerAddress(out SteamDatagramHostedAddress)
public EResult GetHostedDedicatedServerAddress(out SteamDatagramHostedAddress routing)
Parameters
routing
SteamDatagramHostedAddress
Returns
GetHostedDedicatedServerPOPID()
public SteamNetworkingPOPID GetHostedDedicatedServerPOPID()
Returns
GetHostedDedicatedServerPort()
public ushort GetHostedDedicatedServerPort()
Returns
GetIdentity(out SteamNetworkingIdentity)
public bool GetIdentity(out SteamNetworkingIdentity identity)
Parameters
identity
SteamNetworkingIdentity
Returns
GetListenSocketAddress(HSteamListenSocket, out SteamNetworkingIPAddr)
public bool GetListenSocketAddress(HSteamListenSocket socket, out SteamNetworkingIPAddr address)
Parameters
socket
HSteamListenSocketaddress
SteamNetworkingIPAddr
Returns
GetRemoteFakeIPForConnection(HSteamNetConnection, out SteamNetworkingIPAddr)
public EResult GetRemoteFakeIPForConnection(HSteamNetConnection conn, out SteamNetworkingIPAddr outAddr)
Parameters
conn
HSteamNetConnectionoutAddr
SteamNetworkingIPAddr
Returns
InitAuthentication()
public ESteamNetworkingAvailability InitAuthentication()
Returns
OnSteamNetAuthenticationStatus(CallbackAction<SteamNetAuthenticationStatus>)
public IDisposable OnSteamNetAuthenticationStatus(CallbackAction<SteamNetAuthenticationStatus> func)
Parameters
Returns
OnSteamNetConnectionStatusChangedCallback(CallbackAction<SteamNetConnectionStatusChangedCallback>)
public IDisposable OnSteamNetConnectionStatusChangedCallback(CallbackAction<SteamNetConnectionStatusChangedCallback> func)
Parameters
Returns
OnSteamNetworkingFakeIPResult(CallbackAction<SteamNetworkingFakeIPResult>)
public IDisposable OnSteamNetworkingFakeIPResult(CallbackAction<SteamNetworkingFakeIPResult> func)
Parameters
Returns
ReceiveMessagesOnConnection(HSteamNetConnection, Span<SteamNetworkingMessagePtr>)
public int ReceiveMessagesOnConnection(HSteamNetConnection conn, Span<SteamNetworkingMessagePtr> ppOutMessages)
Parameters
conn
HSteamNetConnectionppOutMessages
Span<SteamNetworkingMessagePtr>
Returns
ReceiveMessagesOnPollGroup(HSteamNetPollGroup, Span<SteamNetworkingMessagePtr>)
public int ReceiveMessagesOnPollGroup(HSteamNetPollGroup pollGroup, Span<SteamNetworkingMessagePtr> ppOutMessages)
Parameters
pollGroup
HSteamNetPollGroupppOutMessages
Span<SteamNetworkingMessagePtr>
Returns
ReceivedP2PCustomSignal(ReadOnlySpan<byte>, ref ISteamNetworkingSignalingRecvContext)
public bool ReceivedP2PCustomSignal(ReadOnlySpan<byte> msg, ref ISteamNetworkingSignalingRecvContext context)
Parameters
msg
ReadOnlySpan<byte>context
ISteamNetworkingSignalingRecvContext
Returns
ReceivedRelayAuthTicket(ReadOnlySpan<byte>, out SteamDatagramRelayAuthTicket)
public bool ReceivedRelayAuthTicket(ReadOnlySpan<byte> ticket, out SteamDatagramRelayAuthTicket outParsedTicket)
Parameters
ticket
ReadOnlySpan<byte>outParsedTicket
SteamDatagramRelayAuthTicket
Returns
ResetIdentity(in SteamNetworkingIdentity)
public void ResetIdentity(in SteamNetworkingIdentity identity)
Parameters
identity
SteamNetworkingIdentity
RunCallbacks()
public void RunCallbacks()
SendMessageToConnection(HSteamNetConnection, ReadOnlySpan<byte>, int, out long)
public EResult SendMessageToConnection(HSteamNetConnection conn, ReadOnlySpan<byte> data, int sendFlags, out long outMessageNumber)
Parameters
conn
HSteamNetConnectiondata
ReadOnlySpan<byte>sendFlags
intoutMessageNumber
long
Returns
SendMessages(ReadOnlySpan<SteamNetworkingMessagePtr>, Span<long>)
public void SendMessages(ReadOnlySpan<SteamNetworkingMessagePtr> messages, Span<long> outMessageNumberOrResult)
Parameters
messages
ReadOnlySpan<SteamNetworkingMessagePtr>outMessageNumberOrResult
Span<long>
SetCertificate(ReadOnlySpan<byte>, out string)
public bool SetCertificate(ReadOnlySpan<byte> certificate, out string errMsg)
Parameters
certificate
ReadOnlySpan<byte>errMsg
string
Returns
SetConnectionName(HSteamNetConnection, string)
public void SetConnectionName(HSteamNetConnection peer, string pszName)
Parameters
peer
HSteamNetConnectionpszName
string
SetConnectionPollGroup(HSteamNetConnection, HSteamNetPollGroup)
public bool SetConnectionPollGroup(HSteamNetConnection conn, HSteamNetPollGroup pollGroup)
Parameters
conn
HSteamNetConnectionpollGroup
HSteamNetPollGroup
Returns
SetConnectionUserData(HSteamNetConnection, long)
public bool SetConnectionUserData(HSteamNetConnection peer, long userData)
Parameters
peer
HSteamNetConnectionuserData
long
Returns
UntilAuthentication(CancellationToken)
Initializes authentication and waits until it is ready.
public Promise UntilAuthentication(CancellationToken cancel = default)
Parameters
cancel
CancellationToken
Returns
- Promise
Resolves ONLY when authentication has been successful.
Remarks
Indicate our desire to be ready participate in authenticated communications. If we are currently not ready, then steps will be taken to obtain the necessary certificates. (This includes a certificate for us, as well as any CA certificates needed to authenticate peers.)
You can call this at program init time if you know that you are going to be making authenticated connections, so that we will be ready immediately when those connections are attempted. (Note that essentially all connections require authentication, with the exception of ordinary UDP connections with authentication disabled using k_ESteamNetworkingConfig_IP_AllowWithoutAuth.) If you don't call this function, we will wait until a feature is utilized that that necessitates these resources.
You can also call this function to force a retry, if failure has occurred. Once we make an attempt and fail, we will not automatically retry. In this respect, the behavior of the system after trying and failing is the same as before the first attempt: attempting authenticated communication or calling this function will call the system to attempt to acquire the necessary resources.
You can use GetAuthenticationStatus(out SteamNetAuthenticationStatus) or listen for SteamNetAuthenticationStatus to monitor the status.