Beispiel #1
0
		public static T? CreateOptions<T> (NWProtocolDefinition protocolDefinition) where T: NWProtocolOptions
		{
			if (protocolDefinition == null)
				throw new ArgumentNullException (nameof (protocolDefinition));
			var x = nw_framer_create_options (protocolDefinition.Handle);
			return Runtime.GetINativeObject<T> (x, owns: true);
		}
 public static NWFramerMessage Create(NWProtocolDefinition protocolDefinition)
 {
     if (protocolDefinition == null)
     {
         throw new ArgumentNullException(nameof(protocolDefinition));
     }
     return(new NWFramerMessage(nw_framer_protocol_create_message(protocolDefinition.Handle), owns: true));
 }
        static void TrampolineEnumerateProtocolsHandler(IntPtr block, nw_protocol_definition_t protocol, nuint handshake_milliseconds, nuint handshake_rtt_milliseconds)
        {
            var del = BlockLiteral.GetTarget <Action <NWProtocolDefinition, TimeSpan, TimeSpan> > (block);

            if (del != null)
            {
                using (var nwProtocolDefinition = new NWProtocolDefinition(protocol, owns: false))
                    del(nwProtocolDefinition, TimeSpan.FromMilliseconds(handshake_milliseconds), TimeSpan.FromMilliseconds(handshake_rtt_milliseconds));
            }
        }
Beispiel #4
0
        public T GetProtocolMetadata <T> (NWProtocolDefinition definition) where T : NWProtocolMetadata
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition));
            }

            var x = nw_connection_copy_protocol_metadata(GetCheckedHandle(), definition.Handle);

            return(Runtime.GetINativeObject <T> (x, owns: true));
        }
        public NWProtocolMetadata?GetProtocolMetadata(NWContentContext context, NWProtocolDefinition definition)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (definition is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var ptr = nw_connection_group_copy_protocol_metadata_for_message(GetCheckedHandle(), context.Handle, definition.Handle);

            return(ptr == IntPtr.Zero ? null : new NWProtocolMetadata(ptr, true));
        }
Beispiel #6
0
        public NWProtocolMetadata GetProtocolMetadata(NWProtocolDefinition definition)
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition));
            }

            var x = nw_connection_copy_protocol_metadata(GetCheckedHandle(), definition.Handle);

            if (x == IntPtr.Zero)
            {
                return(null);
            }
            return(new NWProtocolMetadata(x, owns: true));
        }
Beispiel #7
0
        static void TrampolineConfigureHandler(IntPtr block, IntPtr iface)
        {
            var del = BlockLiteral.GetTarget <Action <NWProtocolOptions> > (block);

            if (del != null)
            {
                using (var tempOptions = new NWProtocolOptions(iface, owns: false))
                    using (var definition = tempOptions.ProtocolDefinition) {
                        NWProtocolOptions?castedOptions = null;

                        if (definition.Equals(NWProtocolDefinition.CreateTcpDefinition()))
                        {
                            castedOptions = new NWProtocolTcpOptions(iface, owns: false);
                        }
                        else if (definition.Equals(NWProtocolDefinition.CreateUdpDefinition()))
                        {
                            castedOptions = new NWProtocolUdpOptions(iface, owns: false);
                        }
                        else if (definition.Equals(NWProtocolDefinition.CreateTlsDefinition()))
                        {
                            castedOptions = new NWProtocolTlsOptions(iface, owns: false);
                        }
                        else if (definition.Equals(NWProtocolDefinition.CreateIPDefinition()))
                        {
                            castedOptions = new NWProtocolIPOptions(iface, owns: false);
                        }
                        else if (definition.Equals(NWProtocolDefinition.CreateWebSocketDefinition()))
                        {
                            castedOptions = new NWWebSocketOptions(iface, owns: false);
                        }

                        try {
                            del(castedOptions ?? tempOptions);
                        } finally {
                            castedOptions?.Dispose();
                        }
                    }
            }
        }