public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            hubConnectionBuilder.ConfigureConnectionFactory(() =>
            {
                var headers     = hubConnectionBuilder.GetHeaders();
                var httpOptions = new HttpOptions
                {
                    HttpMessageHandler = hubConnectionBuilder.GetMessageHandler(),
                    Headers            = headers != null ? new ReadOnlyDictionary <string, string>(headers) : null,
                    AccessTokenFactory = hubConnectionBuilder.GetAccessTokenFactory(),
                    WebSocketOptions   = hubConnectionBuilder.GetWebSocketOptions(),
                    Cookies            = hubConnectionBuilder.GetCookies(),
                    Proxy = hubConnectionBuilder.GetProxy(),
                    UseDefaultCredentials = hubConnectionBuilder.GetUseDefaultCredentials(),
                    ClientCertificates    = hubConnectionBuilder.GetClientCertificates(),
                    Credentials           = hubConnectionBuilder.GetCredentials(),
                };

                return(new HttpConnection(url,
                                          hubConnectionBuilder.GetTransport(),
                                          hubConnectionBuilder.GetLoggerFactory(),
                                          httpOptions));
            });
            return(hubConnectionBuilder);
        }
        public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            hubConnectionBuilder.ConfigureConnectionFactory(() =>
            {
                var headers     = hubConnectionBuilder.GetHeaders();
                var httpOptions = new HttpOptions
                {
                    HttpMessageHandler    = hubConnectionBuilder.GetMessageHandler(),
                    Headers               = headers != null ? new ReadOnlyDictionary <string, string>(headers) : null,
                    JwtBearerTokenFactory = hubConnectionBuilder.GetJwtBearerTokenFactory(),
                    WebSocketOptions      = hubConnectionBuilder.GetWebSocketOptions(),
                };

                return(new HttpConnection(url,
                                          hubConnectionBuilder.GetTransport(),
                                          hubConnectionBuilder.GetLoggerFactory(),
                                          httpOptions));
            });
            return(hubConnectionBuilder);
        }
Example #3
0
        public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            hubConnectionBuilder.ConfigureConnectionFactory(() =>
            {
                return(new HttpConnection(url,
                                          hubConnectionBuilder.GetTransport(),
                                          hubConnectionBuilder.GetLoggerFactory(),
                                          hubConnectionBuilder.GetMessageHandler()));
            });
            return(hubConnectionBuilder);
        }