Beispiel #1
0
 void GetMessagesThread()
 {
     while (ispd)
     {
         try
         {
             if (accesstoken != "")
             {
                 string       sEmitResponse = Client.GetStringAsync("messages?api_key=" + accesstoken + "&room=English").Result;
                 chatmessages msgs          = json.JsonDeserialize <chatmessages>(sEmitResponse);
                 bool         pastlast      = false;
                 for (int i = 0; i < msgs.messages.Length; i++)
                 {
                     //if (!pastlast)
                     {
                         pastlast = json.ToDateTime2(msgs.messages[i].timestamp).Ticks > lastchat.Ticks;
                     }
                     if (pastlast)
                     {
                         lastchat = json.ToDateTime2(msgs.messages[i].timestamp);
                         ReceivedChatMessage(lastchat.ToShortTimeString() + "(" + msgs.messages[i].userid + ") <" + msgs.messages[i].username + "> " + msgs.messages[i].message);
                     }
                 }
             }
         }
         catch
         {
         }
         System.Threading.Thread.Sleep(1500);
     }
 }
Beispiel #2
0
        void GetMessagesThread()
        {
            while (ispd)
            {
                try
                {
                    if (accesstoken != "")
                    {
                        HttpWebRequest loginrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/messages?access_token=" + accesstoken + "&room=English");
                        loginrequest.Method = "GET";
                        if (Prox != null)
                        {
                            loginrequest.Proxy = Prox;
                        }
                        loginrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                        HttpWebResponse EmitResponse  = (HttpWebResponse)loginrequest.GetResponse();
                        string          sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();

                        chatmessages msgs     = json.JsonDeserialize <chatmessages>(sEmitResponse);
                        bool         pastlast = false;
                        for (int i = 0; i < msgs.messages.Length; i++)
                        {
                            //if (!pastlast)
                            {
                                pastlast = json.ToDateTime2(msgs.messages[i].timestamp).Ticks > lastchat.Ticks;
                            }
                            if (pastlast)
                            {
                                lastchat = json.ToDateTime2(msgs.messages[i].timestamp);
                                ReceivedChatMessage(lastchat.ToShortTimeString() + "(" + msgs.messages[i].userid + ") <" + msgs.messages[i].username + "> " + msgs.messages[i].message);
                            }
                        }
                    }
                }
                catch
                {
                }
                System.Threading.Thread.Sleep(1000);
            }
        }