protected override void OnSleep() { Debug.WriteLine("OnSleep..."); SignalRClientInstance.Stop(); IsInBackground = true; }
protected override void OnResume() { Debug.WriteLine("OnResume..."); SignalRClientInstance.Start(); IsInBackground = false; }
public App() { InitializeComponent(); LoginPageInstance = new LoginPage(); ChatHerkesPageInstance = new ChatHerkesPage(); if (!IsUserLoggedIn) { Current.MainPage = LoginPageInstance; } else { SetMainPage(); } LoginPageInstance.ConnectSent += (userName) => { Connect(userName); //try to reconnect every 5 seconds, just in case Device.StartTimer(TimeSpan.FromSeconds(5), () => { if (!SignalRClientInstance.IsConnectedOrConnecting && !IsInBackground) { Connect(userName); } return(true); }); }; ChatHerkesPageInstance.BroadcastMessageSent += (user, message) => { SignalRClientInstance.SendBroadcastMessage(user, message); }; ChatHerkesPageInstance.BroadcastMessageTextBoxTextChanged += (user) => { SignalRClientInstance.SendIsTypingMessage(user); }; }