public HubFacade(IConfigurationRoot configuration, ILogger logger) { this.logger = logger; var builder = new HubConnectionBuilder(); builder.AddJsonProtocol(options => { //set serialization options to be able to deserialize interfaces options.PayloadSerializerSettings.TypeNameHandling = TypeNameHandling.Objects; }); var url = configuration.GetValue <string>("HubUrl"); builder.WithUrl(url); logger.LogTrace($"Creating hub for {url}"); if (bool.Parse(configuration["HubDebugLogging"])) { builder.ConfigureLogging(b => { b.AddProvider(new RpiConsoleLoggerProvider()); }); } Client = builder.Build(); Client.Closed += TryReconnect; Client.On <RpiOperationContract>("ServerToClient", ReceiveMessage); }
public void AddJsonProtocolAddsProtocol() { var connectionBuilder = new HubConnectionBuilder(); connectionBuilder.AddJsonProtocol(); var serviceProvider = connectionBuilder.Services.BuildServiceProvider(); var resolvedHubProtocol = serviceProvider.GetService <IHubProtocol>(); Assert.IsType <JsonHubProtocol>(resolvedHubProtocol); }