Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Starting HubOptions #743

Merged
merged 5 commits into from
Aug 23, 2017
Merged

Starting HubOptions #743

merged 5 commits into from
Aug 23, 2017

Conversation

BrennanConroy
Copy link
Member

#254 and #261

Wanted to get feedback to see if this is the design we want. Then I'll add a test.
Do we want it to be HubOptions<THub>?

Current usage:

services.Configure<HubOptions>(options =>
{
    options.JsonSerializerSettings = new JsonSerializerSettings()
    {
        ContractResolver = new CamelCasePropertyNamesContractResolver()
    };
});

@davidfowl
Copy link
Member

This should also work when I call AddSignalR

public IHubProtocol GetProtocol(string protocolName, HubConnectionContext connection)
{
switch (protocolName?.ToLowerInvariant())
{
case "json":
return new JsonHubProtocol(new JsonSerializer());
return new JsonHubProtocol(JsonSerializer.Create(_options.Value.JsonSerializerSettings));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what settings are used if JsonSerializerSettings is null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default ones. Exact same as what we were doing before.

@moozzyk
Copy link
Contributor

moozzyk commented Aug 21, 2017

I don't think we can JSON settings defined by the user to serialize/read our payload

@BrennanConroy
Copy link
Member Author

BrennanConroy commented Aug 21, 2017

It doesn't change any of our items. Example:

await Clients.All.InvokeAsync("Send", $"{Context.ConnectionId} joined", new { Message = "m", TestName = "t" });

Sends:

data received: {"invocationId":"1","type":1,"target":"Send","nonBlocking":true,"arguments":["735fe372-7d10-4a6a-9e69-35d3ece80e85 joined",{"message":"m","testName":"t"}]}�

We use JsonTextWriter for our protocol, just talked with @moozzyk in person

@davidfowl
Copy link
Member

Where's the test?

@@ -9,6 +10,12 @@ public static class SignalRDependencyInjectionExtensions
{
public static ISignalRBuilder AddSignalR(this IServiceCollection services)
{
return AddSignalR(services, o => { });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ => { }

@BrennanConroy
Copy link
Member Author

🆙 📅

Copy link
Contributor

@moozzyk moozzyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

However I wonder if it should be possible to set the options per Hub...

@davidfowl
Copy link
Member

@moozzyk I think so, but we can revisit that after alpha.

@@ -36,16 +37,19 @@ public class HubEndPoint<THub> : IInvocationBinder where THub : Hub
private readonly ILogger<HubEndPoint<THub>> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IHubProtocolResolver _protocolResolver;
private readonly IOptions<HubOptions> _hubOptions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any concrete things to add here for alpha?

@BrennanConroy
Copy link
Member Author

Original issue that has a couple items, none look too important #254

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants