Skip to content

SignalR HubConnectionContext constructors changing #14845

Closed
@jkotalik

Description

@jkotalik

SignalR HubConnectionContext constructors changing

We are changing SignalR's HubConnectionContext constructors to take in an options type rather than multiple parameters to future proof adding options. This removes two constructors in favor of a single constructor which takes an option type.

Version introduced

3.0

Old behavior

Prior to 3.0 HubConnectionContext had two constructors:

public HubConnectionContext(ConnectionContext connectionContext, TimeSpan keepAliveInterval, ILoggerFactory loggerFactory);
public HubConnectionContext(ConnectionContext connectionContext, TimeSpan keepAliveInterval, ILoggerFactory loggerFactory, TimeSpan clientTimeoutInterval);

New behavior

In 3.0 these 2 constructors have been removed and replaced them with a new one:

public HubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)

Reason for change

This new constructor makes use of a new options object, so we can expand the features of HubConnectionContext in the future without making more constructors and breaking changes.

Recommended action

Instead of calling:

HubConnectionContext connectionContext = new HubConnectionContext(
    connectionContext, 
    keepAliveInterval: TimeSpan.FromSeconds(15), 
    loggerFactory, 
    clientTimeoutInterval: TimeSpan.FromSeconds(15));

They would now call:

HubConnectionContextOptions contextOptions = new HubConnectionContextOptions()
{
    KeepAliveInterval = TimeSpan.FromSeconds(15),
    ClientTimeoutInterval = TimeSpan.FromSeconds(15)
};
HubConnectionContext connectionContext = new HubConnectionContext(connectionContext, contextOptions, loggerFactory);

Category

ASP.NET Core

Affected APIs

HubConnectionContext.ctor(ConnectionContext, TimeSpan , ILoggerFactory)

HubConnectionContext.ctor(ConnectionContext, TimeSpan , ILoggerFactory, TimeSpan)


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Labels

breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions