public static IHubConnectionBuilder WithLogger(this IHubConnectionBuilder hubConnectionBuilder, Action <ILoggerFactory> configureLogging) { var loggerFactory = hubConnectionBuilder.GetLoggerFactory() ?? new LoggerFactory(); configureLogging(loggerFactory); return(hubConnectionBuilder.WithLoggerFactory(loggerFactory)); }
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); }
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 HubConnection Build() { if (_connectionFactoryDelegate == null) { throw new InvalidOperationException("Cannot create IConnection instance. The connection factory was not configured."); } IHubConnectionBuilder builder = this; var loggerFactory = builder.GetLoggerFactory(); var hubProtocol = builder.GetHubProtocol(); return(new HubConnection(_connectionFactoryDelegate, hubProtocol ?? new JsonHubProtocol(), loggerFactory)); }
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); }