HubConnection Constructors

Definition

Overloads

HubConnection(IConnectionFactory, IHubProtocol, ILoggerFactory)

Source:
HubConnection.cs
Source:
HubConnection.cs

Initializes a new instance of the HubConnection class.

C#
public HubConnection (Microsoft.AspNetCore.SignalR.Client.IConnectionFactory connectionFactory, Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol protocol, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory);

Parameters

connectionFactory
IConnectionFactory

The IConnectionFactory used to create a connection each time StartAsync(CancellationToken) is called.

protocol
IHubProtocol

The IHubProtocol used by the connection.

loggerFactory
ILoggerFactory

The logger factory.

Applies to

ASP.NET Core 2.2 and ASP.NET Core 2.1
Product Versions
ASP.NET Core 2.1, 2.2

HubConnection(IConnectionFactory, IHubProtocol, IServiceProvider, ILoggerFactory)

Source:
HubConnection.cs
Source:
HubConnection.cs

Initializes a new instance of the HubConnection class.

C#
public HubConnection (Microsoft.AspNetCore.SignalR.Client.IConnectionFactory connectionFactory, Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol protocol, IServiceProvider serviceProvider, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory);

Parameters

connectionFactory
IConnectionFactory

The IConnectionFactory used to create a connection each time StartAsync(CancellationToken) is called.

protocol
IHubProtocol

The IHubProtocol used by the connection.

serviceProvider
IServiceProvider

An IServiceProvider containing the services provided to this HubConnection instance.

loggerFactory
ILoggerFactory

The logger factory.

Remarks

The IServiceProvider used to initialize the connection will be disposed when the connection is disposed.

Applies to

ASP.NET Core 2.2 and ASP.NET Core 2.1
Product Versions
ASP.NET Core 2.1, 2.2

HubConnection(IConnectionFactory, IHubProtocol, EndPoint, IServiceProvider, ILoggerFactory)

Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs

Initializes a new instance of the HubConnection class.

C#
public HubConnection (Microsoft.AspNetCore.Connections.IConnectionFactory connectionFactory, Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol protocol, System.Net.EndPoint endPoint, IServiceProvider serviceProvider, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory);

Parameters

connectionFactory
IConnectionFactory

The IConnectionFactory used to create a connection each time StartAsync(CancellationToken) is called.

protocol
IHubProtocol

The IHubProtocol used by the connection.

endPoint
EndPoint

The EndPoint to connect to.

serviceProvider
IServiceProvider

An IServiceProvider containing the services provided to this HubConnection instance.

loggerFactory
ILoggerFactory

The logger factory.

Remarks

The IServiceProvider used to initialize the connection will be disposed when the connection is disposed.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

HubConnection(IConnectionFactory, IHubProtocol, EndPoint, IServiceProvider, ILoggerFactory, IRetryPolicy)

Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs

Initializes a new instance of the HubConnection class.

C#
public HubConnection (Microsoft.AspNetCore.Connections.IConnectionFactory connectionFactory, Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol protocol, System.Net.EndPoint endPoint, IServiceProvider serviceProvider, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.SignalR.Client.IRetryPolicy reconnectPolicy);

Parameters

connectionFactory
IConnectionFactory

The IConnectionFactory used to create a connection each time StartAsync(CancellationToken) is called.

protocol
IHubProtocol

The IHubProtocol used by the connection.

endPoint
EndPoint

The EndPoint to connect to.

serviceProvider
IServiceProvider

An IServiceProvider containing the services provided to this HubConnection instance.

loggerFactory
ILoggerFactory

The logger factory.

reconnectPolicy
IRetryPolicy

The IRetryPolicy that controls the timing and number of reconnect attempts. The HubConnection will not reconnect if the reconnectPolicy is null.

Remarks

The IServiceProvider used to initialize the connection will be disposed when the connection is disposed.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0