예제 #1
0
        private async Task StartReadTask()
        {
            //Read Message Code
            oldreaded = readed;
            await reader.Read(currChatMode);

            string rusername = reader.GetUser();
            string rmessage  = reader.GetMessage();

            readed             = reader.GetString();
            mainMessages.Text += readed;

            if (this.IsActive == false)
            {
                if (readed != "")
                {
                    if (oldreaded != readed)
                    {
                        messagesUnreaded++;
                        Badge.SetNumber(messagesUnreaded, badge);
                        toaster.Toast(rmessage, rusername);
                        //Toaster.Toast(readed);
                    }
                }
            }

            //Get Errors
            if (reader.GetError(out Exception ex))
            {
                mainMessages.Text += devMode ? "\r\nError 0x0001.  " + ex.Message + "\r\n" + ex.ToString() : "";
                statusDef.Height   = new GridLength(30, GridUnitType.Pixel);
                errorStatus.Text   = ex.Message;
                lastError          = true;
            }
            else
            {
                if (lastError == true)
                {
                    errorStatus.Text = "";
                    HideStatus();
                    errorStatus.Text = "SOMETHING GOING WRONG!!! REPORT THIS BUG IMMEDIATELY!!!";
                    lastError        = false;
                }
            }

            //Wait
            await Task.Delay(currentTimeSpan);

            //Make Loop
            await StartReadTask();
        }