Exemplo n.º 1
0
        private async Task <PNResult <PNChannelMembersResult> > GetMembersList(string spaceId, PNPageObject page, int limit, bool includeCount, string includeOptions, string filter, List <string> sort, Dictionary <string, object> externalQueryParam)
        {
            PNResult <PNChannelMembersResult> ret = new PNResult <PNChannelMembersResult>();

            PNPageObject internalPage;

            if (page == null)
            {
                internalPage = new PNPageObject();
            }
            else
            {
                internalPage = page;
            }

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");

            Uri request = urlBuilder.BuildGetAllMembersRequest("GET", "", spaceId, internalPage.Next, internalPage.Prev, limit, includeCount, includeOptions, filter, sort, externalQueryParam);

            RequestState <PNChannelMembersResult> requestState = new RequestState <PNChannelMembersResult>();

            requestState.ResponseType      = PNOperationType.PNGetChannelMembersOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = false;
            Tuple <string, PNStatus> JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false).ConfigureAwait(false);

            ret.Status = JsonAndStatusTuple.Item2;
            string json = JsonAndStatusTuple.Item1;

            if (!string.IsNullOrEmpty(json))
            {
                List <object>          resultList      = ProcessJsonResponse(requestState, json);
                ResponseBuilder        responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog);
                PNChannelMembersResult responseResult  = responseBuilder.JsonToObject <PNChannelMembersResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        private void GetMembersList(string spaceId, PNPageObject page, int limit, bool includeCount, string includeOptions, string filter, List <string> sort, Dictionary <string, object> externalQueryParam, PNCallback <PNChannelMembersResult> callback)
        {
            PNPageObject internalPage;

            if (page == null)
            {
                internalPage = new PNPageObject();
            }
            else
            {
                internalPage = page;
            }

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");

            Uri request = urlBuilder.BuildGetAllMembersRequest("GET", "", spaceId, internalPage.Next, internalPage.Prev, limit, includeCount, includeOptions, filter, sort, externalQueryParam);

            RequestState <PNChannelMembersResult> requestState = new RequestState <PNChannelMembersResult>();

            requestState.ResponseType      = PNOperationType.PNGetChannelMembersOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = false;
            UrlProcessRequest(request, requestState, false).ContinueWith(r =>
            {
                string json = r.Result.Item1;
                if (!string.IsNullOrEmpty(json))
                {
                    List <object> result = ProcessJsonResponse(requestState, json);
                    ProcessResponseCallbacks(result, requestState);
                }
                else
                {
                    if (r.Result.Item2 != null)
                    {
                        callback.OnResponse(null, r.Result.Item2);
                    }
                }
            }, TaskContinuationOptions.ExecuteSynchronously).Wait();
        }
Exemplo n.º 3
0
        private void GetMembersList(string spaceId, PNPage page, int limit, bool includeCount, string includeOptions, Dictionary <string, object> externalQueryParam, PNCallback <PNGetMembersResult> callback)
        {
            if (callback == null)
            {
                throw new ArgumentException("Missing callback");
            }
            PNPage internalPage;

            if (page == null)
            {
                internalPage = new PNPage();
            }
            else
            {
                internalPage = page;
            }

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr);

            urlBuilder.PubnubInstanceId = (PubnubInstance != null) ? PubnubInstance.InstanceId : "";
            Uri request = urlBuilder.BuildGetAllMembersRequest(spaceId, internalPage.Next, internalPage.Prev, limit, includeCount, includeOptions, externalQueryParam);

            RequestState <PNGetMembersResult> requestState = new RequestState <PNGetMembersResult>();

            requestState.ResponseType      = PNOperationType.PNGetMembersOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            string json = "";

            requestState.UsePostMethod = false;
            json = UrlProcessRequest <PNGetMembersResult>(request, requestState, false);

            if (!string.IsNullOrEmpty(json))
            {
                List <object> result = ProcessJsonResponse <PNGetMembersResult>(requestState, json);
                ProcessResponseCallbacks(result, requestState);
            }
        }