Exemplo n.º 1
0
        internal unsafe QuicRegistration(QuicRegistrationConfig config, IQuicInteropApi nativeApi)
        {
            m_nativeApi = nativeApi;
            QuicHandle *handle = null;
            QuicNativeRegistrationConfig nativeRegConfig = new QuicNativeRegistrationConfig
            {
                AppName          = null,
                ExecutionProfile = config.ExecutionProfile
            };

            if (config.AppName != null)
            {
                int         appNameLength    = config.AppName.Length;
                int         maxAppNameLength = Encoding.UTF8.GetMaxByteCount(appNameLength);
                Span <byte> appNameSpan      = appNameLength < 256 ? stackalloc byte[256] : new byte[maxAppNameLength];

                fixed(byte *appNamePtr = appNameSpan)
                {
                    fixed(char *strNamePtr = config.AppName)
                    {
                        int actualLength = Encoding.UTF8.GetBytes(strNamePtr, appNameLength, appNamePtr, maxAppNameLength);

                        appNameSpan[actualLength] = 0; // null terminator
                    }

                    nativeRegConfig.AppName = appNamePtr;
                    m_nativeApi.RegistrationOpen(&nativeRegConfig, &handle);
                }
            }
            else
            {
                m_nativeApi.RegistrationOpen(&nativeRegConfig, &handle);
            }
            m_handle = handle;
        }
Exemplo n.º 2
0
 public QuicRegistration OpenRegistration(QuicRegistrationConfig registrationConfig)
 {
     return(new QuicRegistration(registrationConfig, m_nativeApi));
 }