Beispiel #1
0
 public HubConnection(string url, HttpConnectionOptions options, bool addMessagePack)
 {
     this.Url     = url;
     this.Options = options;
     this.InternalConnectionId = Guid.NewGuid().ToString();
     HubConnectionManager.AddConnection(this, addMessagePack);
 }
Beispiel #2
0
 public HubConnection(HttpConnectionOptions options)
 {
     this.Options = options;
     this.InternalConnectionId = Guid.NewGuid().ToString();
     JSRuntime.Current.InvokeSync <object>(CREATE_CONNECTION_METHOD,
                                           this.InternalConnectionId,
                                           new DotNetObjectRef(this.Options));
 }
 public HubConnection(IJSRuntime runtime, HttpConnectionOptions options)
 {
     this.runtime = runtime;
     this.Options = options;
     this.InternalConnectionId = Guid.NewGuid().ToString();
     runtime.InvokeSync <object>(CREATE_CONNECTION_METHOD,
                                 this.InternalConnectionId,
                                 DotNetObjectReference.Create(this.Options));
 }
 public InternalHttpConnectionOptions(HttpConnectionOptions options)
 {
     this.Transport         = options.Transport;
     this.LogLevel          = options.LogLevel;
     this.LogMessageContent = options.LogMessageContent;
     this.SkipNegotiation   = options.SkipNegotiation;
     this.EnableMessagePack = options.EnableMessagePack;
     this.Url = options.Url;
     this.HasAccessTokenFactory = options.AccessTokenProvider != null;
 }
Beispiel #5
0
        /// <summary>
        /// Configures the <see cref="HubConnection" /> to use HTTP-based transports to connect to the specified URL.
        /// </summary>
        /// <param name="hubConnectionBuilder">The <see cref="HubConnectionBuilder" /> to configure.</param>
        /// <param name="url">The URL the <see cref="HttpConnection"/> will use.</param>
        /// <returns>The same instance of the <see cref="HubConnectionBuilder"/> for chaining.</returns>
        public static HubConnectionBuilder WithUrl(this HubConnectionBuilder hubConnectionBuilder, string url, Action <HttpConnectionOptions> configureHttpOptions = null)
        {
            if (hubConnectionBuilder == null)
            {
                throw new ArgumentNullException(nameof(hubConnectionBuilder));
            }
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException(nameof(url));
            }

            hubConnectionBuilder.Url = url;
            var opt = new HttpConnectionOptions();

            configureHttpOptions?.Invoke(opt);
            hubConnectionBuilder.Options = opt;
            return(hubConnectionBuilder);
        }