Exemple #1
0
        private void HandleAccountArchiveQueryEnd(vx_evt_base_t eventMessage)
        {
            vx_evt_account_archive_query_end_t evt = eventMessage;

            if (evt.account_handle != _accountHandle)
            {
                return;
            }

            if (_accountArchiveResult.QueryId != evt.query_id || !_accountArchiveResult.Running)
            {
                return;
            }
            _accountArchiveResult = new ArchiveQueryResult(evt);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AccountArchiveResult)));
        }
Exemple #2
0
        private void HandleSessionArchiveQueryEnd(vx_evt_base_t eventMessage)
        {
            vx_evt_session_archive_query_end_t evt = eventMessage;

            Debug.Assert(evt != null);
            if (evt.session_handle != _sessionHandle)
            {
                return;
            }
            if (_sessionArchiveResult.QueryId != evt.query_id || !_sessionArchiveResult.Running)
            {
                return;
            }

            _sessionArchiveResult = new ArchiveQueryResult(evt);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SessionArchiveResult)));
        }
Exemple #3
0
        public IAsyncResult BeginSessionArchiveQuery(DateTime?timeStart, DateTime?timeEnd, string searchText,
                                                     AccountId userId, uint max, string afterId, string beforeId, int firstMessageIndex,
                                                     AsyncCallback callback)
        {
            AssertSessionNotDeleted();
            if (TextState != ConnectionState.Connected)
            {
                throw new InvalidOperationException($"{GetType().Name}: {nameof(TextState)} must equal ChannelState.Connected");
            }
            if (afterId != null && beforeId != null)
            {
                throw new ArgumentException($"{GetType().Name}: Parameters {nameof(afterId)} and {nameof(beforeId)} cannot be used at the same time");
            }
            if (max > 50)
            {
                throw new ArgumentException($"{GetType().Name}: {nameof(max)} cannot be greater than 50");
            }


            var ar = new AsyncNoResult(callback);

            var request = new vx_req_session_archive_query_t
            {
                session_handle      = _sessionHandle,
                max                 = max,
                after_id            = afterId,
                before_id           = beforeId,
                first_message_index = firstMessageIndex,
                search_text         = searchText
            };

            if (timeStart != null && timeStart != DateTime.MinValue)
            {
                request.time_start = (timeStart?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
            }
            if (timeEnd != null && timeEnd != DateTime.MaxValue)
            {
                request.time_end = (timeEnd?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
            }

            if (!AccountId.IsNullOrEmpty(userId))
            {
                request.participant_uri = userId.ToString();
            }

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                vx_resp_session_archive_query_t response;
                try
                {
                    response = VxClient.Instance.EndIssueRequest(result);
                    _sessionArchiveResult = new ArchiveQueryResult(response.query_id);
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SessionArchiveResult)));
                    ar.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    ar.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
            });
            return(ar);
        }
Exemple #4
0
        public IAsyncResult BeginAccountArchiveQuery(DateTime?timeStart, DateTime?timeEnd, string searchText,
                                                     AccountId userId, ChannelId channel, uint max, string afterId, string beforeId, int firstMessageIndex,
                                                     AsyncCallback callback)
        {
            AssertLoggedIn();
            if (userId != null && channel != null)
            {
                throw new ArgumentException($"{GetType().Name}: Parameters {nameof(userId)} and {nameof(channel)} cannot be used at the same time");
            }
            if (afterId != null && beforeId != null)
            {
                throw new ArgumentException($"{GetType().Name}: Parameters {nameof(afterId)} and {nameof(beforeId)} cannot be used at the same time");
            }
            if (max > 50)
            {
                throw new ArgumentException($"{GetType().Name}: {nameof(max)} cannot be greater than 50");
            }

            var ar = new AsyncNoResult(callback);

            var request = new vx_req_account_archive_query_t
            {
                account_handle      = _accountHandle,
                max                 = max,
                after_id            = afterId,
                before_id           = beforeId,
                first_message_index = firstMessageIndex
            };

            if (timeStart != null && timeStart != DateTime.MinValue)
            {
                request.time_start = timeStart?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            }
            if (timeEnd != null && timeEnd != DateTime.MaxValue)
            {
                request.time_end = timeEnd?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            }
            request.search_text = searchText;
            if (userId != null)
            {
                request.participant_uri = userId.ToString();
            }
            else if (channel != null)
            {
                request.participant_uri = channel.ToString();
            }

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                vx_resp_account_archive_query_t response;
                try
                {
                    response = VxClient.Instance.EndIssueRequest(result);
                    _accountArchiveResult = new ArchiveQueryResult(response.query_id);
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AccountArchiveResult)));
                    ar.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    ar.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
            });
            return(ar);
        }