Beispiel #1
0
        public void FireEvent <T> (string message, bool isError, bool isTimeout, RequestState <T> pubnubRequestState, CurrentRequestType crt)
        {
            CustomEventArgs <T> cea = new CustomEventArgs <T> ();

            cea.PubnubRequestState = pubnubRequestState;
            cea.Message            = message;
            cea.IsError            = isError;
            cea.IsTimeout          = isTimeout;
            cea.CurrRequestType    = crt;
            #if (ENABLE_PUBNUB_LOGGING)
            LoggingMethod.WriteToLog(string.Format("DateTime {0}, Raising Event of type : {1}", DateTime.Now.ToString(), crt.ToString()), LoggingMethod.LevelInfo);
            #endif

            if ((crt == CurrentRequestType.Heartbeat) && (heartbeatCoroutineComplete != null))
            {
                heartbeatCoroutineComplete.Raise(this, cea);
            }
            else if ((crt == CurrentRequestType.PresenceHeartbeat) && (presenceHeartbeatCoroutineComplete != null))
            {
                presenceHeartbeatCoroutineComplete.Raise(this, cea);
            }
            else if ((crt == CurrentRequestType.Subscribe) && (subCoroutineComplete != null))
            {
                subCoroutineComplete.Raise(this, cea);
            }
            else if ((crt == CurrentRequestType.NonSubscribe) && (nonSubCoroutineComplete != null))
            {
                nonSubCoroutineComplete.Raise(this, cea);
            }
            #if (ENABLE_PUBNUB_LOGGING)
            else
            {
                LoggingMethod.WriteToLog(string.Format("DateTime {0}, Request Type not matched {1}", DateTime.Now.ToString(), crt.ToString()), LoggingMethod.LevelInfo);
            }
            #endif
        }
Beispiel #2
0
        internal static void CreateErrorCodeAndCallErrorCallback <T> (int statusCode, CustomEventArgs <T> cea, RequestState <T> requestState,
                                                                      PubnubErrorFilter.Level errorLevel)
        {
            PubnubClientError error = new PubnubClientError(statusCode, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server,
                                                            requestState.Request, requestState.Response, cea.Message, requestState.ChannelEntities);

            PubnubCallbacks.CallErrorCallback <T> (requestState.ErrorCallback, requestState.ChannelEntities,
                                                   error, errorLevel);
        }