예제 #1
0
        protected override void OnSleep()
        {
            Debug.WriteLine("OnSleep...");
            SignalRClientInstance.Stop();

            IsInBackground = true;
        }
예제 #2
0
        protected override void OnResume()
        {
            Debug.WriteLine("OnResume...");
            SignalRClientInstance.Start();

            IsInBackground = false;
        }
예제 #3
0
        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);
            };
        }