Esempio n. 1
0
        private IEnumerable <ConnectionInitAsyncDelegate> OnConfigureConnection(IFtpConnection connection)
        {
            var eventArgs = new ConnectionEventArgs(connection);

            ConfigureConnection?.Invoke(this, eventArgs);
            return(eventArgs.AsyncInitFunctions);
        }
Esempio n. 2
0
        private HubConnection buildConnection(CancellationToken cancellationToken)
        {
            var builder = new HubConnectionBuilder()
                          .WithUrl(endpoint, options =>
            {
                options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
                options.Headers.Add("OsuVersionHash", versionHash);
            });

            if (RuntimeInfo.SupportsJIT)
            {
                builder.AddMessagePackProtocol();
            }
            else
            {
                // eventually we will precompile resolvers for messagepack, but this isn't working currently
                // see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308.
                builder.AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; });
            }

            var newConnection = builder.Build();

            ConfigureConnection?.Invoke(newConnection);

            newConnection.Closed += ex => onConnectionClosed(ex, cancellationToken);
            return(newConnection);
        }
Esempio n. 3
0
        private HubConnection buildConnection(CancellationToken cancellationToken)
        {
            var builder = new HubConnectionBuilder()
                          .WithUrl(endpoint, options =>
            {
                // Use HttpClient.DefaultProxy once on net6 everywhere.
                // The credential setter can also be removed at this point.
                options.Proxy = WebRequest.DefaultWebProxy;
                if (options.Proxy != null)
                {
                    options.Proxy.Credentials = CredentialCache.DefaultCredentials;
                }

                options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
                options.Headers.Add("OsuVersionHash", versionHash);
            });

            if (RuntimeInfo.SupportsJIT && preferMessagePack)
            {
                builder.AddMessagePackProtocol(options =>
                {
                    options.SerializerOptions = SignalRUnionWorkaroundResolver.OPTIONS;
                });
            }
            else
            {
                // eventually we will precompile resolvers for messagepack, but this isn't working currently
                // see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308.
                builder.AddNewtonsoftJsonProtocol(options =>
                {
                    options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                    options.PayloadSerializerSettings.Converters            = new List <JsonConverter>
                    {
                        new SignalRDerivedTypeWorkaroundJsonConverter(),
                    };
                });
            }

            var newConnection = builder.Build();

            ConfigureConnection?.Invoke(newConnection);

            newConnection.Closed += ex => onConnectionClosed(ex, cancellationToken);
            return(newConnection);
        }
Esempio n. 4
0
        private HubConnection buildConnection(CancellationToken cancellationToken)
        {
            var builder = new HubConnectionBuilder()
                          .WithUrl(endpoint, options =>
            {
                options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
                options.Headers.Add("OsuVersionHash", versionHash);
            });

            if (RuntimeInfo.SupportsJIT && preferMessagePack)
            {
                builder.AddMessagePackProtocol(options =>
                {
                    options.SerializerOptions = SignalRUnionWorkaroundResolver.OPTIONS;
                });
            }
            else
            {
                // eventually we will precompile resolvers for messagepack, but this isn't working currently
                // see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308.
                builder.AddNewtonsoftJsonProtocol(options =>
                {
                    options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                    // TODO: This should only be required to be `TypeNameHandling.Auto`.
                    // See usage in osu-server-spectator for further documentation as to why this is required.
                    options.PayloadSerializerSettings.TypeNameHandling = TypeNameHandling.All;
                });
            }

            var newConnection = builder.Build();

            ConfigureConnection?.Invoke(newConnection);

            newConnection.Closed += ex => onConnectionClosed(ex, cancellationToken);
            return(newConnection);
        }
Esempio n. 5
0
 private void OnConfigureConnection(FtpConnection connection)
 {
     ConfigureConnection?.Invoke(this, new ConnectionEventArgs(connection));
 }