示例#1
0
 public void AddEndpoint(NWEndpoint endpoint)
 {
     if (endpoint == null)
     {
         throw new ArgumentNullException(nameof(endpoint));
     }
     nw_group_descriptor_add_endpoint(GetCheckedHandle(), endpoint.GetCheckedHandle());
 }
示例#2
0
        public NWMulticastGroup(NWEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            InitializeHandle(nw_group_descriptor_create_multicast(endpoint.GetCheckedHandle()));
        }
示例#3
0
        static void TrampolineGatewaysHandler(IntPtr block, IntPtr endpoint)
        {
            var del = BlockLiteral.GetTarget <Action <NWEndpoint> > (block);

            if (del != null)
            {
                var nwEndpoint = new NWEndpoint(endpoint, owns: false);
                del(nwEndpoint);
            }
        }
示例#4
0
        static void TrampolineAdvertisedEndpointChangedHandler(IntPtr block, IntPtr endpoint, byte added)
        {
            var del = BlockLiteral.GetTarget <AdvertisedEndpointChanged> (block);

            if (del != null)
            {
                using var nwendpoint = new NWEndpoint(endpoint, owns: false);
                del(nwendpoint, added != 0 ? true : false);
            }
        }
        static void TrampolineResolutionEnumeratorHandler(IntPtr block, NWReportResolutionSource source, nuint milliseconds, int endpoint_count, nw_endpoint_t successful_endpoint, nw_endpoint_t preferred_endpoint)
        {
            var del = BlockLiteral.GetTarget <Action <NWReportResolutionSource, TimeSpan, int, NWEndpoint, NWEndpoint> > (block);

            if (del != null)
            {
                using (var nwSuccesfulEndpoint = new NWEndpoint(successful_endpoint, owns: false))
                    using (var nwPreferredEndpoint = new NWEndpoint(preferred_endpoint, owns: false))
                        del(source, TimeSpan.FromMilliseconds(milliseconds), endpoint_count, nwSuccesfulEndpoint, nwPreferredEndpoint);
            }
        }
示例#6
0
 public NWConnection(NWEndpoint endpoint, NWParameters parameters)
 {
     if (endpoint == null)
     {
         throw new ArgumentNullException(nameof(endpoint));
     }
     if (parameters == null)
     {
         throw new ArgumentNullException(nameof(parameters));
     }
     InitializeHandle(nw_connection_create(endpoint.Handle, parameters.Handle));
 }
示例#7
0
        public NWResolverConfig(NWEndpoint urlEndpoint, NWResolverConfigEndpointType endpointType)
        {
            if (urlEndpoint is null)
            {
                throw new ArgumentNullException(nameof(urlEndpoint));
            }
            switch (endpointType)
            {
            case NWResolverConfigEndpointType.Https:
                InitializeHandle(nw_resolver_config_create_https(urlEndpoint.Handle));
                break;

            case NWResolverConfigEndpointType.Tls:
                InitializeHandle(nw_resolver_config_create_tls(urlEndpoint.Handle));
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown endpoint type: {endpointType}");
            }
        }
示例#8
0
 public void AddServerAddress(NWEndpoint serverAddress)
 => nw_resolver_config_add_server_address(GetCheckedHandle(), serverAddress.Handle);
        public NWConnection?ExtractConnection(NWEndpoint endpoint, NWProtocolOptions protocolOptions)
        {
            var ptr = nw_connection_group_extract_connection(GetCheckedHandle(), endpoint.GetCheckedHandle(), protocolOptions.GetCheckedHandle());

            return(ptr == IntPtr.Zero ? null : new NWConnection(ptr, true));
        }
示例#10
0
 public NWMultiplexGroup(NWEndpoint endpoint)
     : base(nw_group_descriptor_create_multiplex(endpoint.GetCheckedHandle()), true)
 {
 }