Example #1
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vx_req_account_create_auto_accept_rule_t obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Example #2
0
        public IAsyncResult BeginAddAllowedSubscription(AccountId userId, AsyncCallback callback)
        {
            AssertLoggedIn();
            AsyncNoResult ar = new AsyncNoResult(callback);

            if (_allowedSubscriptions.Contains((userId)))
            {
                ar.SetCompletedSynchronously();
                return(ar);
            }
            if (_incomingSubscriptionRequests.Contains(userId))
            {
                var request = new vx_req_account_send_subscription_reply_t();
                request.account_handle = _accountHandle;
                request.buddy_uri      = userId.ToString();
                request.rule_type      = vx_rule_type.rule_allow;
                VxClient.Instance.BeginIssueRequest(request, result =>
                {
                    try
                    {
                        VxClient.Instance.EndIssueRequest(result);
                        _incomingSubscriptionRequests.RemoveAll(userId);
                        ar.SetComplete();
                    }
                    catch (Exception e)
                    {
                        VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                        ar.SetComplete(e);
                        return;
                    }
                });
                return(ar);
            }
            else
            {
                var request = new vx_req_account_create_auto_accept_rule_t
                {
                    account_handle   = _accountHandle,
                    auto_accept_mask = userId.ToString()
                };
                VxClient.Instance.BeginIssueRequest(request, result =>
                {
                    try
                    {
                        VxClient.Instance.EndIssueRequest(result);
                        _allowedSubscriptions.Add(userId);
                        ar.SetComplete();
                    }
                    catch (Exception e)
                    {
                        VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                        ar.SetComplete(e);
                        if (VivoxDebug.Instance.throwInternalExcepetions)
                        {
                            throw;
                        }
                        return;
                    }
                });
                return(ar);
            }
        }