public ChannelService(IServiceProvider serviceProvider) { //_serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _cancellationSource = new CancellationTokenSource(); _appConfig = serviceProvider.GetRequiredService <IAppSettingsConfig>(); _logger = serviceProvider.GetRequiredService <ILogger>(); _database = serviceProvider.GetRequiredService <IDatabase>(); _dataAdapter = serviceProvider.GetRequiredService <IChannelDataAdapter>(); _scanner = serviceProvider.GetRequiredService <IMessageScanner>(); _receiver = serviceProvider.GetRequiredService <IMessageReceiver>(); _channelStatus = serviceProvider.GetRequiredService <ChannelStatus>(); //_publisher = new MessagePublisher(this); _scanner.NewMessages += Scanner_NewMessages; _channelStatus.PropertyChanged += ChannelStatus_Changed; _mainChannelSettings = _appConfig.MainChannelSettings(); _channelSettings = _appConfig.ChannelSettings(); _databaseSettings = _appConfig.DatabaseSettings(); _messageSettings = _appConfig.MessageSettings(); //_serviceSettings = _appConfig.ServiceSettings(); this.ProcessId = Process.GetCurrentProcess().Id; this.VirtAddress = _mainChannelSettings.VirtAddress; }
//[HubMethodName("")] public IDictionary <string, object> Login(string accessKey) { MainChannelSettings settings = _appConfig.MainChannelSettings(); if ((accessKey ?? "") == settings.PasswordIn) { string connectionId = this.Context.ConnectionId; if (!_connections.TryGet(connectionId, out IHubConnection connection)) { IChannelHubClient client = this.Clients.Client(connectionId); connection = new HubConnection(connectionId, client); _connections.Add(connection); _channelService.SendMessages += SendMessages; _channelService.StatusChanged += StatusChanged; } return(ChannelInfo()); } else { return(null); } }
public static void SetRealAddress(this MainChannelSettings mainSettings, string realAddress) { mainSettings.SetValue(".RealAddress", realAddress); }