Exemple #1
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);
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vx_req_session_archive_query_t obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }