private async void OnLogin() { bool validateServerAddresses = true; if (rocketChat.ServerAddress == string.Empty) { toastService.ShowErrorToastNotification("Błąd połączenia", "Nie ustawiono adresu serwera http Rocket.Chat."); validateServerAddresses = false; } if (rocketChatRealtime.ServerAddress == string.Empty) { toastService.ShowErrorToastNotification("Błąd połączenia", "Nie ustawiono adresu serwera websocket Rocket.Chat."); validateServerAddresses = false; } if (!validateServerAddresses) { return; } ButtonsEnabled = false; bool result; try { result = await rocketChat.Login(Username, Password); await rocketChatRealtime.Connect(); ButtonsEnabled = true; } catch { ButtonsEnabled = true; return; } if (result && rocketChatRealtime.IsConnected) { navigationService.Navigate(PageTokens.ChatPage, ""); } else { if (!rocketChatRealtime.IsConnected) { rocketChat.Logout(); return; } Username = string.Empty; Password = string.Empty; IsPopupOpened = true; await Task.Delay(TimeSpan.FromSeconds(3)); IsPopupOpened = false; } }
private void OnLogout() { rocketChatRest.Logout(); realtimeApi.DisposeSocket(); navigationService.Navigate(PageTokens.MainPage, new { logout = true }); }