Пример #1
0
        public IAsyncResult BeginSendText(string language, string message, string applicationStanzaNamespace,
                                          string applicationStanzaBody, AsyncCallback callback)
        {
            AssertSessionNotDeleted();

            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (TextState != ConnectionState.Connected)
            {
                throw new InvalidOperationException($"{GetType().Name}: TextState must equal ChannelState.Connected");
            }
            var ar      = new AsyncNoResult(callback);
            var request = new vx_req_session_send_message_t
            {
                session_handle          = _sessionHandle,
                message_body            = message,
                application_stanza_body = applicationStanzaBody,
                language = language,
                application_stanza_namespace = applicationStanzaNamespace
            };

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                try
                {
                    VxClient.Instance.EndIssueRequest(result);
                    ar.SetComplete();
                }
                catch (VivoxApiException e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    ar.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
                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_send_message_t obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }