private void RefreshMessages() { GMessageCollection s = this.GetAllMessages(); if (s == null) { return; } if (Tracking == null) { Tracking = new MessageTracking(); foreach (GMessageGroup w in s.conversationgroup) { Tracking.AddMessages(w.call); } return; } foreach (GMessageGroup w in s.conversationgroup) { List <GMessage> gmsg = Tracking.FindUnreadMessages(w.call); if (gmsg.Count > 0) { foreach (GMessage x in gmsg) { if (x.MessageType == MessageType.Received) { this.OnMessageReceived.Invoke(this, new MessageReceivedEvent(x)); } } } } }
public GMessageCollection GetAllMessages() { try { string send_url = string.Format("{0}/x?m=init&v=13", this.init_url); string output = this.POST(send_url, this.get_gvx(), this.init_url); output = output.Replace(")]}',\n", ""); JObject l = JObject.Parse(output); JsonSerializer ser = new JsonSerializer(); GMessageCollection g = (GMessageCollection)ser.Deserialize(new JTokenReader(l["conversations_response"]), typeof(GMessageCollection)); return(g); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }