Beispiel #1
0
 private void CheckNewMessages()
 {
     try
     {
         while (true)
         {
             TMsg[] messages = client.ReceiveUnread(Login);
             if (messages != null)
             {
                 foreach (var msg in messages)
                 {
                     if (msg.from == "ServerCommand")
                     {
                         ServerCommandsCenter(msg.body);
                         continue;
                     }
                     if (msg.type == "Private")
                     {
                         Dispatcher.BeginInvoke((Action) delegate()
                         {
                             Show_Push("Новое приватное сообщение!", "pmsg");
                             Chat.addMess(msg.from + " : " + msg.body);
                         });
                         continue;
                     }
                     Show_Push("Новое сообщение от " + msg.body, "msg");
                     addMes(msg.from + " : " + msg.body);
                 }
             }
             System.Threading.Thread.Sleep(RefreshSpeed);
         }
     }
     catch (EndpointNotFoundException e)
     {
         Dispatcher.Invoke(delegate()
         {
             App.Current.Shutdown();
         });
     }
 }