| 
 | 1 | +using Unity.Networking.Transport;  | 
 | 2 | + | 
 | 3 | +namespace Unity.Netcode.Transports.UTP  | 
 | 4 | +{  | 
 | 5 | +    /// <summary>  | 
 | 6 | +    /// <para>  | 
 | 7 | +    /// This interface allows one to override the creation of the <see cref="NetworkDriver"/> object  | 
 | 8 | +    /// that will be used under the hood by <see cref="UnityTransport"/>. This can be useful when  | 
 | 9 | +    /// implementing a custom <see cref="INetworkInterface"/> or to add custom pipeline stages to  | 
 | 10 | +    /// the default pipelines.  | 
 | 11 | +    /// </para>  | 
 | 12 | +    /// <para>  | 
 | 13 | +    /// To use a custom driver constructor, set <see cref="UnityTransport.s_DriverConstructor"/> to  | 
 | 14 | +    /// an instance of an implementation of this interface. This must be done before calling  | 
 | 15 | +    /// <see cref="UnityTransport.StartClient"/> or <see cref="UnityTransport.StartServer"/>.  | 
 | 16 | +    /// </para>  | 
 | 17 | +    /// </summary>  | 
 | 18 | +    /// <example>  | 
 | 19 | +    /// <para>  | 
 | 20 | +    /// This example implements a custom driver constructor that uses the IPC network interface from  | 
 | 21 | +    /// the Unity Transport package. This network interface is used for intra-process communications  | 
 | 22 | +    /// which can be useful for implementing a single-player version of a game. Since the example is  | 
 | 23 | +    /// also preserving all the default settings and pipelines, you'd also benefit from all the  | 
 | 24 | +    /// existing features of the transport, like integration with the Network Profiler.  | 
 | 25 | +    /// </para>  | 
 | 26 | +    /// <code>  | 
 | 27 | +    ///     public class IPCDriverConstructor : INetworkStreamDriverConstructor  | 
 | 28 | +    ///     {  | 
 | 29 | +    ///         public void CreateDriver(  | 
 | 30 | +    ///             UnityTransport transport,  | 
 | 31 | +    ///             out NetworkDriver driver,  | 
 | 32 | +    ///             out NetworkPipeline unreliableFragmentedPipeline,  | 
 | 33 | +    ///             out NetworkPipeline unreliableSequencedFragmentedPipeline,  | 
 | 34 | +    ///             out NetworkPipeline reliableSequencedPipeline)  | 
 | 35 | +    ///         {  | 
 | 36 | +    ///             var settings = transport.GetDefaultNetworkSettings();  | 
 | 37 | +    ///             driver = NetworkDriver.Create(new IPCNetworkInterface(), settings);  | 
 | 38 | +    ///  | 
 | 39 | +    ///             transport.GetDefaultPipelineConfigurations(  | 
 | 40 | +    ///                 out var unreliableFragmentedPipelineStages,  | 
 | 41 | +    ///                 out var unreliableSequencedFragmentedPipelineStages,  | 
 | 42 | +    ///                 out var reliableSequencedPipelineStages);  | 
 | 43 | +    ///  | 
 | 44 | +    ///             unreliableFragmentedPipeline = driver.CreatePipeline(unreliableFragmentedPipelineStages);  | 
 | 45 | +    ///             unreliableSequencedFragmentedPipeline = driver.CreatePipeline(unreliableSequencedFragmentedPipelineStages);  | 
 | 46 | +    ///             reliableSequencedPipeline = driver.CreatePipeline(reliableSequencedPipelineStages);  | 
 | 47 | +    ///         }  | 
 | 48 | +    ///     }  | 
 | 49 | +    /// </code>  | 
 | 50 | +    /// </example>  | 
 | 51 | +    public interface INetworkStreamDriverConstructor  | 
 | 52 | +    {  | 
 | 53 | +        /// <summary>  | 
 | 54 | +        /// Creates the <see cref="NetworkDriver"/> instance to be used by the transport.  | 
 | 55 | +        /// </summary>  | 
 | 56 | +        /// <param name="transport">The transport for which the driver is created.</param>  | 
 | 57 | +        /// <param name="driver">The newly-created <see cref="NetworkDriver"/>.</param>  | 
 | 58 | +        /// <param name="unreliableFragmentedPipeline">  | 
 | 59 | +        /// The driver's pipeline on which to send unreliable traffic. This pipeline must also  | 
 | 60 | +        /// support fragmentation (payloads larger than the MTU).  | 
 | 61 | +        /// </param>  | 
 | 62 | +        /// <param name="unreliableSequencedFragmentedPipeline">  | 
 | 63 | +        /// The driver's pipeline on which to send unreliable but sequenced traffic. Traffic sent  | 
 | 64 | +        /// on this pipeline must be delivered in the right order, although packet loss is okay.  | 
 | 65 | +        /// This pipeline must also support fragmentation (payloads larger than the MTU).  | 
 | 66 | +        /// </param>  | 
 | 67 | +        /// <param name="reliableSequencedPipeline">  | 
 | 68 | +        /// The driver's pipeline on which to send reliable traffic. This pipeline must ensure that  | 
 | 69 | +        /// all of its traffic is delivered, and in the correct order too. There is no need for that  | 
 | 70 | +        /// pipeline to support fragmentation (<see cref="UnityTransport"/> will handle that).  | 
 | 71 | +        /// </param>  | 
 | 72 | +        void CreateDriver(  | 
 | 73 | +            UnityTransport transport,  | 
 | 74 | +            out NetworkDriver driver,  | 
 | 75 | +            out NetworkPipeline unreliableFragmentedPipeline,  | 
 | 76 | +            out NetworkPipeline unreliableSequencedFragmentedPipeline,  | 
 | 77 | +            out NetworkPipeline reliableSequencedPipeline);  | 
 | 78 | +    }  | 
 | 79 | +}  | 
0 commit comments