protected override async Task OnInitAsync() { _sendHandle = SignalService.Register <string>("Send", addItem); await SignalService.Connect(); forecasts = await ForecastService.GetForecastAsync(DateTime.Now); }
private async Task Connect() { try { logTable = await CloudService.GetTableAsync <Log>(); ICollection <Log> logs = await logTable.ReadAllItemsAsync(); Items.AddRange(logs.OrderByDescending(x => x.CreatedAt)); if (SynthesizerSettings == null || string.IsNullOrWhiteSpace(SynthesizerSettings.AppServiceUrl) || string.IsNullOrWhiteSpace(SynthesizerSettings.SynthesizerApiUrl)) { LogAction("Settings are not configured"); return; } LogAction($"Connecting to {SynthesizerSettings.AppServiceUrl}"); signalService = new SignalService(SynthesizerSettings.AppServiceUrl); signalService.MessageReceived += SignalMessageReceived; LogAction($"Connected to {SynthesizerSettings.AppServiceUrl}"); string connectResponse = await signalService.Connect(); LogAction(connectResponse); UserId = GetCurrentUserId(); string joinGroupResponse = await signalService.JoinGroup(UserId); LogAction(joinGroupResponse); valveRestService = new ValveRestService(SynthesizerSettings.SynthesizerApiUrl); oligoSynthesizerRestService = new OligoSynthesizerRestService(SynthesizerSettings.SynthesizerApiUrl, LogAction); } catch (Exception ex) { LogAction($"Connection failed: {ex.Message}"); } }