Пример #1
0
        public async Task SyncAllNewEventsAsync(long last_sync_timestamp)
        {
            SyncAllNewEventsRequest request = new SyncAllNewEventsRequest()
            {
                request_header          = RequestHeaderBody,
                last_sync_timestamp     = last_sync_timestamp * 1000,
                max_response_size_bytes = 1048576
            };

            using (HttpResponseMessage message = await _client.PostProtoJson("conversations/syncallnewevents", _api_key, request))
            {
                SyncAllNewEventsResponse response = await message.Content.ReadAsProtoJson <SyncAllNewEventsResponse>();

                foreach (var conversation in response.conversation_state)
                {
                    if (_active_conversations.ContainsKey(conversation.conversation_id.id))
                    {
                        _active_conversations[conversation.conversation_id.id].conversation             = conversation.conversation;
                        _active_conversations[conversation.conversation_id.id].event_continuation_token = conversation.event_continuation_token;
                        _active_conversations[conversation.conversation_id.id].events.AddRange(conversation.events);
                        OnConversationUpdated(this, _active_conversations[conversation.conversation_id.id]);
                    }
                    else
                    {
                        _active_conversations.Add(conversation.conversation_id.id, conversation);
                        OnNewConversationCreated(this, conversation);
                    }
                }
            }
        }
Пример #2
0
        public async Task SyncAllNewEventsAsync(long last_sync_timestamp)
        {
            SyncAllNewEventsRequest request = new SyncAllNewEventsRequest()
            {
                request_header          = RequestHeaderBody,
                last_sync_timestamp     = last_sync_timestamp * 1000,
                max_response_size_bytes = 1048576
            };

            using (HttpResponseMessage message = await _client.PostProtoJson("conversations/syncallnewevents", _api_key, request))
            {
                SyncAllNewEventsResponse response = await message.Content.ReadAsProtoJson <SyncAllNewEventsResponse>();

                foreach (var conversation in response.conversation_state)
                {
                    _active_conversations[conversation.conversation_id.id].AddNewMessage(conversation.events);
                }
            }
        }