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
connHSteamNetConnection
Returns
BeginAsyncRequestFakeIP(int)
public bool BeginAsyncRequestFakeIP(int numPorts)
Parameters
numPortsint
Returns
CloseConnection(HSteamNetConnection, int, string?, bool)
public bool CloseConnection(HSteamNetConnection peer, int reason = 0, string? pszDebug = null, bool enableLinger = false)
Parameters
peerHSteamNetConnectionreasonintpszDebugstringenableLingerbool
Returns
CloseListenSocket(HSteamListenSocket)
public bool CloseListenSocket(HSteamListenSocket socket)
Parameters
socketHSteamListenSocket
Returns
ConfigureConnectionLanes(HSteamNetConnection, ReadOnlySpan<int>, ReadOnlySpan<ushort>)
public EResult ConfigureConnectionLanes(HSteamNetConnection conn, ReadOnlySpan<int> lanePriorities, ReadOnlySpan<ushort> laneWeights)
Parameters
connHSteamNetConnectionlanePrioritiesReadOnlySpan<int>laneWeightsReadOnlySpan<ushort>
Returns
ConnectByIPAddress(in SteamNetworkingIPAddr, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamNetConnection ConnectByIPAddress(in SteamNetworkingIPAddr address, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
addressSteamNetworkingIPAddroptionsReadOnlySpan<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
identityRemoteSteamNetworkingIdentityThe identity of the peer to connect to.
remoteVirtualPortintThe port to connect on (usually 0).
optionsReadOnlySpan<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
signalingISteamNetworkingConnectionSignalingpeerIdentitySteamNetworkingIdentityremoteVirtualPortintoptionsReadOnlySpan<SteamNetworkingConfigValue>
Returns
ConnectToHostedDedicatedServer(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamNetConnection ConnectToHostedDedicatedServer(in SteamNetworkingIdentity identityTarget, int remoteVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
identityTargetSteamNetworkingIdentityremoteVirtualPortintoptionsReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateFakeUDPPort(int)
public ISteamNetworkingFakeUDPPort CreateFakeUDPPort(int idxFakeServerPort)
Parameters
idxFakeServerPortint
Returns
CreateHostedDedicatedServerListenSocket(int, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamListenSocket CreateHostedDedicatedServerListenSocket(int localVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localVirtualPortintoptionsReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateListenSocketIP(in SteamNetworkingIPAddr, ReadOnlySpan<SteamNetworkingConfigValue>)
public HSteamListenSocket CreateListenSocketIP(in SteamNetworkingIPAddr localAddress, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localAddressSteamNetworkingIPAddroptionsReadOnlySpan<SteamNetworkingConfigValue>
Returns
CreateListenSocketP2P(int, ReadOnlySpan<SteamNetworkingConfigValue>)
Listen for connection by CSteamID through the Valve network.
public HSteamListenSocket CreateListenSocketP2P(int localVirtualPort, ReadOnlySpan<SteamNetworkingConfigValue> options)
Parameters
localVirtualPortintThe port to use in ConnectP2P(in SteamNetworkingIdentity, int, ReadOnlySpan<SteamNetworkingConfigValue>) .
optionsReadOnlySpan<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
idxFakePortintoptionsReadOnlySpan<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
outConnection1HSteamNetConnectionoutConnection2HSteamNetConnectionuseNetworkLoopbackboolidentity1SteamNetworkingIdentityidentity2SteamNetworkingIdentity
Returns
DestroyPollGroup(HSteamNetPollGroup)
public bool DestroyPollGroup(HSteamNetPollGroup pollGroup)
Parameters
pollGroupHSteamNetPollGroup
Returns
FindRelayAuthTicketForServer(in SteamNetworkingIdentity, int, out SteamDatagramRelayAuthTicket)
public int FindRelayAuthTicketForServer(in SteamNetworkingIdentity identityGameServer, int remoteVirtualPort, out SteamDatagramRelayAuthTicket outParsedTicket)
Parameters
identityGameServerSteamNetworkingIdentityremoteVirtualPortintoutParsedTicketSteamDatagramRelayAuthTicket
Returns
FlushMessagesOnConnection(HSteamNetConnection)
public EResult FlushMessagesOnConnection(HSteamNetConnection conn)
Parameters
connHSteamNetConnection
Returns
GetAuthenticationStatus(out SteamNetAuthenticationStatus)
public ESteamNetworkingAvailability GetAuthenticationStatus(out SteamNetAuthenticationStatus details)
Parameters
detailsSteamNetAuthenticationStatus
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
connHSteamNetConnectioninfoSteamNetConnectionInfo
Returns
GetConnectionName(HSteamNetConnection, Span<byte>)
public bool GetConnectionName(HSteamNetConnection peer, Span<byte> pszName)
Parameters
peerHSteamNetConnectionpszNameSpan<byte>
Returns
GetConnectionRealTimeStatus(HSteamNetConnection, out SteamNetConnectionRealTimeStatus, Span<SteamNetConnectionRealTimeLaneStatus>)
public EResult GetConnectionRealTimeStatus(HSteamNetConnection conn, out SteamNetConnectionRealTimeStatus status, Span<SteamNetConnectionRealTimeLaneStatus> lanes)
Parameters
connHSteamNetConnectionstatusSteamNetConnectionRealTimeStatuslanesSpan<SteamNetConnectionRealTimeLaneStatus>
Returns
GetConnectionUserData(HSteamNetConnection)
public long GetConnectionUserData(HSteamNetConnection peer)
Parameters
peerHSteamNetConnection
Returns
GetDetailedConnectionStatus(HSteamNetConnection, Span<byte>)
public int GetDetailedConnectionStatus(HSteamNetConnection conn, Span<byte> pszBuf)
Parameters
connHSteamNetConnectionpszBufSpan<byte>
Returns
GetFakeIP(int, out SteamNetworkingFakeIPResult)
public void GetFakeIP(int idxFirstPort, out SteamNetworkingFakeIPResult info)
Parameters
idxFirstPortintinfoSteamNetworkingFakeIPResult
GetGameCoordinatorServerLogin(ref SteamDatagramGameCoordinatorServerLogin, out int, Span<byte>)
public EResult GetGameCoordinatorServerLogin(ref SteamDatagramGameCoordinatorServerLogin loginInfo, out int signedBlobCount, Span<byte> blob)
Parameters
loginInfoSteamDatagramGameCoordinatorServerLoginsignedBlobCountintblobSpan<byte>
Returns
GetHostedDedicatedServerAddress(out SteamDatagramHostedAddress)
public EResult GetHostedDedicatedServerAddress(out SteamDatagramHostedAddress routing)
Parameters
routingSteamDatagramHostedAddress
Returns
GetHostedDedicatedServerPOPID()
public SteamNetworkingPOPID GetHostedDedicatedServerPOPID()
Returns
GetHostedDedicatedServerPort()
public ushort GetHostedDedicatedServerPort()
Returns
GetIdentity(out SteamNetworkingIdentity)
public bool GetIdentity(out SteamNetworkingIdentity identity)
Parameters
identitySteamNetworkingIdentity
Returns
GetListenSocketAddress(HSteamListenSocket, out SteamNetworkingIPAddr)
public bool GetListenSocketAddress(HSteamListenSocket socket, out SteamNetworkingIPAddr address)
Parameters
socketHSteamListenSocketaddressSteamNetworkingIPAddr
Returns
GetRemoteFakeIPForConnection(HSteamNetConnection, out SteamNetworkingIPAddr)
public EResult GetRemoteFakeIPForConnection(HSteamNetConnection conn, out SteamNetworkingIPAddr outAddr)
Parameters
connHSteamNetConnectionoutAddrSteamNetworkingIPAddr
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
connHSteamNetConnectionppOutMessagesSpan<SteamNetworkingMessagePtr>
Returns
ReceiveMessagesOnPollGroup(HSteamNetPollGroup, Span<SteamNetworkingMessagePtr>)
public int ReceiveMessagesOnPollGroup(HSteamNetPollGroup pollGroup, Span<SteamNetworkingMessagePtr> ppOutMessages)
Parameters
pollGroupHSteamNetPollGroupppOutMessagesSpan<SteamNetworkingMessagePtr>
Returns
ReceivedP2PCustomSignal(ReadOnlySpan<byte>, ref ISteamNetworkingSignalingRecvContext)
public bool ReceivedP2PCustomSignal(ReadOnlySpan<byte> msg, ref ISteamNetworkingSignalingRecvContext context)
Parameters
msgReadOnlySpan<byte>contextISteamNetworkingSignalingRecvContext
Returns
ReceivedRelayAuthTicket(ReadOnlySpan<byte>, out SteamDatagramRelayAuthTicket)
public bool ReceivedRelayAuthTicket(ReadOnlySpan<byte> ticket, out SteamDatagramRelayAuthTicket outParsedTicket)
Parameters
ticketReadOnlySpan<byte>outParsedTicketSteamDatagramRelayAuthTicket
Returns
ResetIdentity(in SteamNetworkingIdentity)
public void ResetIdentity(in SteamNetworkingIdentity identity)
Parameters
identitySteamNetworkingIdentity
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
connHSteamNetConnectiondataReadOnlySpan<byte>sendFlagsintoutMessageNumberlong
Returns
SendMessages(ReadOnlySpan<SteamNetworkingMessagePtr>, Span<long>)
public void SendMessages(ReadOnlySpan<SteamNetworkingMessagePtr> messages, Span<long> outMessageNumberOrResult)
Parameters
messagesReadOnlySpan<SteamNetworkingMessagePtr>outMessageNumberOrResultSpan<long>
SetCertificate(ReadOnlySpan<byte>, out string)
public bool SetCertificate(ReadOnlySpan<byte> certificate, out string errMsg)
Parameters
certificateReadOnlySpan<byte>errMsgstring
Returns
SetConnectionName(HSteamNetConnection, string)
public void SetConnectionName(HSteamNetConnection peer, string pszName)
Parameters
peerHSteamNetConnectionpszNamestring
SetConnectionPollGroup(HSteamNetConnection, HSteamNetPollGroup)
public bool SetConnectionPollGroup(HSteamNetConnection conn, HSteamNetPollGroup pollGroup)
Parameters
connHSteamNetConnectionpollGroupHSteamNetPollGroup
Returns
SetConnectionUserData(HSteamNetConnection, long)
public bool SetConnectionUserData(HSteamNetConnection peer, long userData)
Parameters
peerHSteamNetConnectionuserDatalong
Returns
UntilAuthentication(CancellationToken)
Initializes authentication and waits until it is ready.
public Promise UntilAuthentication(CancellationToken cancel = default)
Parameters
cancelCancellationToken
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.