public IAsyncResult BeginAddPresenceSubscription(AccountId userId, AsyncCallback callback) { AssertLoggedIn(); var ar = new AsyncResult <IPresenceSubscription>(callback); if (_presenceSubscriptions.ContainsKey((userId))) { ar.SetCompletedSynchronously(_presenceSubscriptions[userId]); return(ar); } var request = new vx_req_account_buddy_set_t { account_handle = _accountHandle, buddy_uri = userId.ToString() }; VxClient.Instance.BeginIssueRequest(request, result => { try { VxClient.Instance.EndIssueRequest(result); _presenceSubscriptions[userId] = new PresenceSubscription { Key = userId }; ar.SetComplete(_presenceSubscriptions[userId]); BeginRemoveBlockedSubscription(userId, ar2 => { try { EndRemoveBlockedSubscription(ar2); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); ar.SetComplete(e); if (VivoxDebug.Instance.throwInternalExcepetions) { throw; } return; } BeginAddAllowedSubscription(userId, ar3 => { try { EndAddAllowedSubscription(ar3); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); ar.SetComplete(e); if (VivoxDebug.Instance.throwInternalExcepetions) { throw; } return; } }); }); } catch (Exception e) { VivoxDebug.Instance.DebugMessage($"{GetType().Name}: {request.GetType().Name} failed {e}", vx_log_level.log_error); ar.SetComplete(e); return; } }); return(ar); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vx_req_account_buddy_set_t obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }