VK API. getLongPollServer и getLongPollHistory. Почему ловит не все события? Работает не каждый раз, пробовал выводить new_pts, иногда пропускаются некоторые значения. Так же не работает в беседах. Код ниже. Что не так?
static void Main(string[] args)
{
connectToLongPool();
while (true)
{
scanMessages();
Thread.Sleep(500);
}
public static string ts;
public static string pts;
public static string new_pts = "1";
private static void connectToLongPool()
{
HttpWebRequest pollReq = (HttpWebRequest)WebRequest.Create("https://api.vk.com/method/messages.getLongPollServer?access_token=токен_от_группы&need_pts=" + new_pts + "&v=5.92");
pollReq.Method = "GET";
pollReq.Accept = "application/json";
HttpWebResponse pollResp = (HttpWebResponse)pollReq.GetResponse();
StreamReader reader = new StreamReader(pollResp.GetResponseStream());
StringBuilder builder = new StringBuilder();
string pollData = builder.Append(reader.ReadToEnd()).ToString();
JObject poolConnectJson = JObject.Parse(pollData);
ts = poolConnectJson["response"]["ts"].ToString();
pts = poolConnectJson["response"]["pts"].ToString();
}
private static void scanMessages()
{
HttpWebRequest poolMessages = (HttpWebRequest)WebRequest.Create("https://api.vk.com/method/messages.getLongPollHistory?group_id=190776459&ts=" + ts + "&access_token=" + "токен_группы&v=5.92" + "&pts=" + pts + "&lp_version=3&msgs_limit=10000&events_limit=10000");
poolMessages.Method = "GET";
poolMessages.Accept = "application/json";
HttpWebResponse poolResponse = (HttpWebResponse)poolMessages.GetResponse();
StreamReader reader = new StreamReader(poolResponse.GetResponseStream());
StringBuilder builder = new StringBuilder();
string textResp = builder.Append(reader.ReadToEnd()).ToString();
JObject poolConnectJson = JObject.Parse(textResp);
Console.WriteLine(textResp);
//MsgPrint(poolConnectJson);
new_pts = poolConnectJson["response"]["new_pts"].ToString();
Console.WriteLine(new_pts);
}