Ejemplo n.º 1
0
        void StartHeartbeat(bool pause, int pauseTime)
        {
            try {
                if (!this.PubNubInstance.PNConfig.ReconnectionPolicy.Equals(PNReconnectionPolicy.NONE))
                {
                    isHearbeatRunning = true;

                    Uri request = BuildRequests.BuildTimeRequest(
                        this.PubNubInstance
                        );

                    RequestState requestState = new RequestState();
                    requestState.OperationType = PNOperationType.PNHeartbeatOperation;
                    requestState.URL           = request.OriginalString;
                    requestState.Timeout       = PubNubInstance.PNConfig.NonSubscribeTimeout;
                    requestState.Pause         = pauseTime;
                    requestState.Reconnect     = pause;

                    #if (ENABLE_PUBNUB_LOGGING)
                    this.PubNubInstance.PNLog.WriteToLog(string.Format("heartbeat: request.OriginalString {0} ", request.OriginalString), PNLoggingMethod.LevelInfo);
                    #endif

                    webRequestId = webRequest.Run(requestState);

                    #if (ENABLE_PUBNUB_LOGGING)
                    this.PubNubInstance.PNLog.WriteToLog(string.Format("StartHeartbeat: Heartbeat running"), PNLoggingMethod.LevelInfo);
                    #endif
                }
            }
            catch (Exception ex) {
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog(string.Format("StartHeartbeat: Heartbeat exception {0}", ex.ToString()), PNLoggingMethod.LevelError);
                #endif
            }
        }
        protected override void RunWebRequest(QueueManager qm)
        {
            RequestState requestState = new RequestState();

            requestState.OperationType = OperationType;

            Uri request = BuildRequests.BuildTimeRequest(
                this.PubNubInstance
                );

            #if (ENABLE_PUBNUB_LOGGING)
            this.PubNubInstance.PNLog.WriteToLog(string.Format("RunTimeRequest {0}", request.OriginalString), PNLoggingMethod.LevelInfo);
            #endif
            base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
        }