예제 #1
0
파일: VxClient.cs 프로젝트: pyr53540/vivox
        public IAsyncResult BeginIssueRequest(vx_req_base_t request, AsyncCallback callback)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }
            if (!Started)
            {
                throw new InvalidOperationException();
            }
            string requestId = $"{_nextRequestId++}";

            request.cookie = requestId;
            var result = new AsyncResult <vx_resp_base_t>(callback)
            {
                AsyncState = requestId
            };

            lock (_pendingRequests)
            {
                _pendingRequests[requestId] = result;
            }
            var status = VivoxCoreInstance.IssueRequest(request);

            if (status != 0)
            {
                lock (_pendingRequests)
                {
                    _pendingRequests.Remove(requestId);
                }
                throw new VivoxApiException(status);
            }
            return(result);
        }