Exemplo n.º 1
0
        internal void History(string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMsgActions, Dictionary <string, object> externalQueryParam, PNCallback <PNFetchHistoryResult> callback)
        {
            if (channels == null || channels.Length == 0 || string.IsNullOrEmpty(channels[0]) || string.IsNullOrEmpty(channels[0].Trim()))
            {
                throw new ArgumentException("Missing Channel(s)");
            }
            string channel = string.Join(",", channels);

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

            Uri request = urlBuilder.BuildFetchRequest("GET", "", channels, start, end, count, reverse, includeMeta, includeMsgActions, externalQueryParam);

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

            requestState.Channels          = new[] { channel };
            requestState.ResponseType      = PNOperationType.PNFetchHistoryOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            UrlProcessRequest(request, requestState, false).ContinueWith(r =>
            {
                string json = r.Result.Item1;
                if (!string.IsNullOrEmpty(json))
                {
                    List <object> result = ProcessJsonResponse(requestState, json);
                    ProcessResponseCallbacks(result, requestState);
                }
            }, TaskContinuationOptions.ExecuteSynchronously).Wait();
        }
Exemplo n.º 2
0
        internal void History(PNCallback <PNFetchHistoryResult> callback)
        {
            if (this.channelNames == null || this.channelNames.Length == 0 || string.IsNullOrEmpty(this.channelNames[0]) || string.IsNullOrEmpty(this.channelNames[0].Trim()))
            {
                throw new ArgumentException("Missing Channel(s)");
            }
            string channel = string.Join(",", this.channelNames);

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

            Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.queryParam);

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

            requestState.Channels          = new[] { channel };
            requestState.ResponseType      = PNOperationType.PNFetchHistoryOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            UrlProcessRequest(request, requestState, false).ContinueWith(r =>
            {
                string json = r.Result.Item1;
                if (!string.IsNullOrEmpty(json))
                {
                    List <object> result = ProcessJsonResponse(requestState, json);
                    ProcessResponseCallbacks(result, requestState);
                }
            }, TaskContinuationOptions.ExecuteSynchronously).Wait();
        }
Exemplo n.º 3
0
        internal async Task <PNResult <PNFetchHistoryResult> > History(string[] channels, long start, long end, int count, bool reverse, bool includeMeta, bool includeMsgActions, Dictionary <string, object> externalQueryParam)
        {
            if (channels == null || channels.Length == 0 || string.IsNullOrEmpty(channels[0]) || string.IsNullOrEmpty(channels[0].Trim()))
            {
                throw new ArgumentException("Missing Channel(s)");
            }
            PNResult <PNFetchHistoryResult> ret = new PNResult <PNFetchHistoryResult>();
            string channel = string.Join(",", channels);

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

            Uri request = urlBuilder.BuildFetchRequest("GET", "", channels, start, end, count, reverse, includeMeta, includeMsgActions, externalQueryParam);

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

            requestState.Channels          = new[] { channel };
            requestState.ResponseType      = PNOperationType.PNFetchHistoryOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            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);
                PNFetchHistoryResult responseResult  = responseBuilder.JsonToObject <PNFetchHistoryResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }
Exemplo n.º 4
0
        internal async Task <PNResult <PNFetchHistoryResult> > History()
        {
            if (this.channelNames == null || this.channelNames.Length == 0 || string.IsNullOrEmpty(this.channelNames[0]) || string.IsNullOrEmpty(this.channelNames[0].Trim()))
            {
                throw new ArgumentException("Missing Channel(s)");
            }
            PNResult <PNFetchHistoryResult> ret = new PNResult <PNFetchHistoryResult>();
            string channel = string.Join(",", this.channelNames);

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

            Uri request = urlBuilder.BuildFetchRequest("GET", "", this.channelNames, this.startTimetoken, this.endTimetoken, this.perChannelCount, this.reverseOption, this.withMetaOption, this.withMessageActionsOption, this.withUuidOption, this.includeMessageType, this.queryParam);

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

            requestState.Channels          = new[] { channel };
            requestState.ResponseType      = PNOperationType.PNFetchHistoryOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            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);
                PNFetchHistoryResult responseResult  = responseBuilder.JsonToObject <PNFetchHistoryResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }