// Copyright Epic Games, Inc. All Rights Reserved. // This file is automatically generated. Changes to this file may be overwritten. namespace Epic.OnlineServices.P2P { public sealed partial class P2PInterface : Handle { public P2PInterface() { } public P2PInterface(System.IntPtr innerHandle) : base(innerHandle) { } /// /// The most recent version of the API. /// public const int AcceptconnectionApiLatest = 1; /// /// The most recent version of the API. /// public const int AddnotifyincomingpacketqueuefullApiLatest = 1; /// /// The most recent version of the API. /// public const int AddnotifypeerconnectionclosedApiLatest = 1; /// /// The most recent version of the API. /// public const int AddnotifypeerconnectionrequestApiLatest = 1; /// /// The most recent version of the API. /// public const int CloseconnectionApiLatest = 1; /// /// The most recent version of the API. /// public const int CloseconnectionsApiLatest = 1; /// /// The most recent version of the API. /// public const int GetnattypeApiLatest = 1; /// /// The most recent version of the API. /// public const int GetnextreceivedpacketsizeApiLatest = 2; /// /// The most recent version of the API. /// public const int GetpacketqueueinfoApiLatest = 1; /// /// The most recent version of the API. /// public const int GetportrangeApiLatest = 1; /// /// The most recent version of the API. /// public const int GetrelaycontrolApiLatest = 1; /// /// The maximum amount of unique Socket ID connections that can be opened with each remote user. As this limit is only per remote user, you may have more /// than this number of Socket IDs across multiple remote users. /// public const int MaxConnections = 32; /// /// A packet's maximum size in bytes /// public const int MaxPacketSize = 1170; /// /// Helper constant to signify that the packet queue is allowed to grow indefinitely /// public const int MaxQueueSizeUnlimited = 0; /// /// The most recent version of the API. /// public const int QuerynattypeApiLatest = 1; /// /// The most recent version of the API. /// public const int ReceivepacketApiLatest = 2; /// /// The most recent version of the API. /// public const int SendpacketApiLatest = 2; /// /// The most recent version of the API. /// public const int SetpacketqueuesizeApiLatest = 1; /// /// The most recent version of the API. /// public const int SetportrangeApiLatest = 1; /// /// The most recent version of the API. /// public const int SetrelaycontrolApiLatest = 1; /// /// The most recent version of the structure. /// public const int SocketidApiLatest = 1; /// /// Accept connections from a specific peer. If this peer has not attempted to connect yet, when they do, they will automatically be accepted. /// /// Information about who would like to accept a connection, and which connection /// /// :: - if the provided data is valid /// :: - if the provided data is invalid /// public Result AcceptConnection(AcceptConnectionOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_AcceptConnection(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Listen for when our packet queue has become full. This event gives an opportunity to read packets to make /// room for new incoming packets. If this event fires and no packets are read by calling /// or the packet queue size is not increased by , any packets that are received after /// this event are discarded until there is room again in the queue. /// /// Information about what version of the API is supported /// Arbitrary data that is passed back to you in the CompletionDelegate /// The callback to be fired when the incoming packet queue is full /// /// A valid notification ID if successfully bound, or otherwise /// public ulong AddNotifyIncomingPacketQueueFull(AddNotifyIncomingPacketQueueFullOptions options, object clientData, OnIncomingPacketQueueFullCallback incomingPacketQueueFullHandler) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var clientDataAddress = System.IntPtr.Zero; var incomingPacketQueueFullHandlerInternal = new OnIncomingPacketQueueFullCallbackInternal(OnIncomingPacketQueueFullCallbackInternalImplementation); Helper.AddCallback(ref clientDataAddress, clientData, incomingPacketQueueFullHandler, incomingPacketQueueFullHandlerInternal); var funcResult = Bindings.EOS_P2P_AddNotifyIncomingPacketQueueFull(InnerHandle, optionsAddress, clientDataAddress, incomingPacketQueueFullHandlerInternal); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult); return funcResult; } /// /// Listen for when a previously opened connection is closed. /// /// Information about who would like notifications about closed connections, and for which socket /// This value is returned to the caller when ConnectionClosedHandler is invoked /// The callback to be fired when we an open connection has been closed /// /// A valid notification ID if successfully bound, or otherwise /// public ulong AddNotifyPeerConnectionClosed(AddNotifyPeerConnectionClosedOptions options, object clientData, OnRemoteConnectionClosedCallback connectionClosedHandler) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var clientDataAddress = System.IntPtr.Zero; var connectionClosedHandlerInternal = new OnRemoteConnectionClosedCallbackInternal(OnRemoteConnectionClosedCallbackInternalImplementation); Helper.AddCallback(ref clientDataAddress, clientData, connectionClosedHandler, connectionClosedHandlerInternal); var funcResult = Bindings.EOS_P2P_AddNotifyPeerConnectionClosed(InnerHandle, optionsAddress, clientDataAddress, connectionClosedHandlerInternal); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult); return funcResult; } /// /// Listen for incoming connection requests on a particular Socket ID, or optionally all Socket IDs. The bound function /// will only be called if the connection has not already been accepted. /// /// Information about who would like notifications, and (optionally) only for a specific socket /// This value is returned to the caller when ConnectionRequestHandler is invoked /// The callback to be fired when we receive a connection request /// /// A valid notification ID if successfully bound, or otherwise /// public ulong AddNotifyPeerConnectionRequest(AddNotifyPeerConnectionRequestOptions options, object clientData, OnIncomingConnectionRequestCallback connectionRequestHandler) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var clientDataAddress = System.IntPtr.Zero; var connectionRequestHandlerInternal = new OnIncomingConnectionRequestCallbackInternal(OnIncomingConnectionRequestCallbackInternalImplementation); Helper.AddCallback(ref clientDataAddress, clientData, connectionRequestHandler, connectionRequestHandlerInternal); var funcResult = Bindings.EOS_P2P_AddNotifyPeerConnectionRequest(InnerHandle, optionsAddress, clientDataAddress, connectionRequestHandlerInternal); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult); return funcResult; } /// /// Stop accepting new connections from a specific peer and close any open connections. /// /// Information about who would like to close a connection, and which connection. /// /// :: - if the provided data is valid /// :: - if the provided data is invalid /// public Result CloseConnection(CloseConnectionOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_CloseConnection(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Close any open Connections for a specific Peer Connection ID. /// /// Information about who would like to close connections, and by what socket ID /// /// :: - if the provided data is valid /// :: - if the provided data is invalid /// public Result CloseConnections(CloseConnectionsOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_CloseConnections(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Get our last-queried NAT-type, if it has been successfully queried. /// /// Information about what version of the API is supported /// The queried NAT Type, or unknown if unknown /// /// :: - if we have cached data /// :: - If we do not have queried data cached /// public Result GetNATType(GetNATTypeOptions options, out NATType outNATType) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); outNATType = Helper.GetDefault(); var funcResult = Bindings.EOS_P2P_GetNATType(InnerHandle, optionsAddress, ref outNATType); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Gets the size of the packet that will be returned by ReceivePacket for a particular user, if there is any available /// packets to be retrieved. /// /// Information about who is requesting the size of their next packet /// The amount of bytes required to store the data of the next packet for the requested user /// /// :: - If OutPacketSizeBytes was successfully set and there is data to be received /// :: - If input was invalid /// :: - If there are no packets available for the requesting user /// public Result GetNextReceivedPacketSize(GetNextReceivedPacketSizeOptions options, out uint outPacketSizeBytes) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); outPacketSizeBytes = Helper.GetDefault(); var funcResult = Bindings.EOS_P2P_GetNextReceivedPacketSize(InnerHandle, optionsAddress, ref outPacketSizeBytes); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Gets the current cached information related to the incoming and outgoing packet queues. /// /// Information about what version of the API is supported /// The current information of the incoming and outgoing packet queues /// /// :: - if the input options were valid /// :: - if the input was invalid in some way /// public Result GetPacketQueueInfo(GetPacketQueueInfoOptions options, out PacketQueueInfo outPacketQueueInfo) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var outPacketQueueInfoInternal = Helper.GetDefault(); var funcResult = Bindings.EOS_P2P_GetPacketQueueInfo(InnerHandle, optionsAddress, ref outPacketQueueInfoInternal); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryMarshalGet(outPacketQueueInfoInternal, out outPacketQueueInfo); return funcResult; } /// /// Get the current chosen port and the amount of other ports to try above the chosen port if the chosen port is unavailable. /// /// Information about what version of the API is supported /// The port that will be tried first /// The amount of ports to try above the value in OutPort, if OutPort is unavailable /// /// :: - if the input options were valid /// :: - if the input was invalid in some way /// public Result GetPortRange(GetPortRangeOptions options, out ushort outPort, out ushort outNumAdditionalPortsToTry) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); outPort = Helper.GetDefault(); outNumAdditionalPortsToTry = Helper.GetDefault(); var funcResult = Bindings.EOS_P2P_GetPortRange(InnerHandle, optionsAddress, ref outPort, ref outNumAdditionalPortsToTry); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Get the current relay control setting. /// /// Information about what version of the API is supported /// The relay control setting currently configured /// /// :: - if the input was valid /// :: - if the input was invalid in some way /// public Result GetRelayControl(GetRelayControlOptions options, out RelayControl outRelayControl) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); outRelayControl = Helper.GetDefault(); var funcResult = Bindings.EOS_P2P_GetRelayControl(InnerHandle, optionsAddress, ref outRelayControl); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Query the current NAT-type of our connection. /// /// Information about what version of the API is supported /// arbitrary data that is passed back to you in the CompletionDelegate /// The callback to be fired when we finish querying our NAT type public void QueryNATType(QueryNATTypeOptions options, object clientData, OnQueryNATTypeCompleteCallback completionDelegate) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var clientDataAddress = System.IntPtr.Zero; var completionDelegateInternal = new OnQueryNATTypeCompleteCallbackInternal(OnQueryNATTypeCompleteCallbackInternalImplementation); Helper.AddCallback(ref clientDataAddress, clientData, completionDelegate, completionDelegateInternal); Bindings.EOS_P2P_QueryNATType(InnerHandle, optionsAddress, clientDataAddress, completionDelegateInternal); Helper.TryMarshalDispose(ref optionsAddress); } /// /// Receive the next packet for the local user, and information associated with this packet, if it exists. /// /// Information about who is requesting the size of their next packet, and how much data can be stored safely /// The Remote User who sent data. Only set if there was a packet to receive. /// The Socket ID of the data that was sent. Only set if there was a packet to receive. /// The channel the data was sent on. Only set if there was a packet to receive. /// Buffer to store the data being received. Must be at least in length or data will be truncated /// The amount of bytes written to OutData. Only set if there was a packet to receive. /// /// :: - If the packet was received successfully /// :: - If input was invalid /// :: - If there are no packets available for the requesting user /// public Result ReceivePacket(ReceivePacketOptions options, out ProductUserId outPeerId, out SocketId outSocketId, out byte outChannel, out byte[] outData) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var outPeerIdAddress = System.IntPtr.Zero; var outSocketIdInternal = Helper.GetDefault(); outChannel = Helper.GetDefault(); System.IntPtr outDataAddress = System.IntPtr.Zero; uint outBytesWritten = MaxPacketSize; Helper.TryMarshalAllocate(ref outDataAddress, outBytesWritten); var funcResult = Bindings.EOS_P2P_ReceivePacket(InnerHandle, optionsAddress, ref outPeerIdAddress, ref outSocketIdInternal, ref outChannel, outDataAddress, ref outBytesWritten); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryMarshalGet(outPeerIdAddress, out outPeerId); Helper.TryMarshalGet(outSocketIdInternal, out outSocketId); Helper.TryMarshalGet(outDataAddress, out outData, outBytesWritten); Helper.TryMarshalDispose(ref outDataAddress); return funcResult; } /// /// Stop listening for full incoming packet queue events on a previously bound handler. /// /// The previously bound notification ID public void RemoveNotifyIncomingPacketQueueFull(ulong notificationId) { Helper.TryRemoveCallbackByNotificationId(notificationId); Bindings.EOS_P2P_RemoveNotifyIncomingPacketQueueFull(InnerHandle, notificationId); } /// /// Stop notifications for connections being closed on a previously bound handler. /// /// The previously bound notification ID public void RemoveNotifyPeerConnectionClosed(ulong notificationId) { Helper.TryRemoveCallbackByNotificationId(notificationId); Bindings.EOS_P2P_RemoveNotifyPeerConnectionClosed(InnerHandle, notificationId); } /// /// Stop listening for connection requests on a previously bound handler. /// /// The previously bound notification ID public void RemoveNotifyPeerConnectionRequest(ulong notificationId) { Helper.TryRemoveCallbackByNotificationId(notificationId); Bindings.EOS_P2P_RemoveNotifyPeerConnectionRequest(InnerHandle, notificationId); } /// /// Send a packet to a peer at the specified address. If there is already an open connection to this peer, it will be /// sent immediately. If there is no open connection, an attempt to connect to the peer will be made. An /// result only means the data was accepted to be sent, not that it has been successfully delivered to the peer. /// /// Information about the data being sent, by who, to who /// /// :: - If packet was queued to be sent successfully /// :: - If input was invalid /// :: - If amount of data being sent is too large, or the outgoing packet queue was full /// public Result SendPacket(SendPacketOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_SendPacket(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Sets the maximum packet queue sizes that packets waiting to be sent or received can use. If the packet queue /// size is made smaller than the current queue size while there are packets in the queue that would push this /// packet size over, existing packets are kept but new packets may not be added to the full queue until enough /// packets are sent or received. /// /// Information about packet queue size /// /// :: - if the input options were valid /// :: - if the input was invalid in some way /// public Result SetPacketQueueSize(SetPacketQueueSizeOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_SetPacketQueueSize(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Set configuration options related to network ports. /// /// Information about network ports config options /// /// :: - if the options were set successfully /// :: - if the options are invalid in some way /// public Result SetPortRange(SetPortRangeOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_SetPortRange(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } /// /// Set how relay servers are to be used. This setting does not immediately apply to existing connections, but may apply to existing /// connections if the connection requires renegotiation. /// /// Information about relay server config options /// /// :: - if the options were set successfully /// :: - if the options are invalid in some way /// public Result SetRelayControl(SetRelayControlOptions options) { var optionsAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref optionsAddress, options); var funcResult = Bindings.EOS_P2P_SetRelayControl(InnerHandle, optionsAddress); Helper.TryMarshalDispose(ref optionsAddress); return funcResult; } [MonoPInvokeCallback(typeof(OnIncomingConnectionRequestCallbackInternal))] internal static void OnIncomingConnectionRequestCallbackInternalImplementation(System.IntPtr data) { OnIncomingConnectionRequestCallback callback; OnIncomingConnectionRequestInfo callbackInfo; if (Helper.TryGetAndRemoveCallback(data, out callback, out callbackInfo)) { callback(callbackInfo); } } [MonoPInvokeCallback(typeof(OnIncomingPacketQueueFullCallbackInternal))] internal static void OnIncomingPacketQueueFullCallbackInternalImplementation(System.IntPtr data) { OnIncomingPacketQueueFullCallback callback; OnIncomingPacketQueueFullInfo callbackInfo; if (Helper.TryGetAndRemoveCallback(data, out callback, out callbackInfo)) { callback(callbackInfo); } } [MonoPInvokeCallback(typeof(OnQueryNATTypeCompleteCallbackInternal))] internal static void OnQueryNATTypeCompleteCallbackInternalImplementation(System.IntPtr data) { OnQueryNATTypeCompleteCallback callback; OnQueryNATTypeCompleteInfo callbackInfo; if (Helper.TryGetAndRemoveCallback(data, out callback, out callbackInfo)) { callback(callbackInfo); } } [MonoPInvokeCallback(typeof(OnRemoteConnectionClosedCallbackInternal))] internal static void OnRemoteConnectionClosedCallbackInternalImplementation(System.IntPtr data) { OnRemoteConnectionClosedCallback callback; OnRemoteConnectionClosedInfo callbackInfo; if (Helper.TryGetAndRemoveCallback(data, out callback, out callbackInfo)) { callback(callbackInfo); } } } }