internal static void FireErrorCallback <T> (string activeChannel, SafeDictionary <PubnubChannelCallbackKey, object> channelCallbacks, bool callbackObjectType, ResponseType responseType, PubnubErrorFilter.Level errorLevel, PubnubClientError error) { var callbackKey = GetPubnubChannelCallbackKey(activeChannel, responseType); PubnubChannelCallback <T> currentPubnubCallback = null; if (channelCallbacks.Count > 0 && channelCallbacks.ContainsKey(callbackKey)) { if (callbackObjectType) { object callbackObject; bool channelAvailable = channelCallbacks.TryGetValue(callbackKey, out callbackObject); if (channelAvailable) { currentPubnubCallback = callbackObject as PubnubChannelCallback <T>; } } else { currentPubnubCallback = channelCallbacks [callbackKey] as PubnubChannelCallback <T>; } if (currentPubnubCallback != null && currentPubnubCallback.ErrorCallback != null) { GoToCallback(error, currentPubnubCallback.ErrorCallback, errorLevel); } } }
internal static void FireErrorCallback <T> (ChannelEntity channelEntity, PubnubErrorFilter.Level errorLevel, PubnubClientError error) { PubnubChannelCallback <T> channelCallback = channelEntity.ChannelParams.Callbacks as PubnubChannelCallback <T>; if (channelCallback != null) { GoToCallback(error, channelCallback.ErrorCallback, errorLevel); } }
internal static void CallCallbackKnownType <T>(PubnubChannelCallbackKey callbackKey, SafeDictionary <PubnubChannelCallbackKey, object> channelCallbacks, IJsonPluggableLibrary jsonPluggableLibrary, List <object> itemMessage) { PubnubChannelCallback <T> currentPubnubCallback = channelCallbacks[callbackKey] as PubnubChannelCallback <T>; if (currentPubnubCallback != null && currentPubnubCallback.Callback != null) { GoToCallback(itemMessage, currentPubnubCallback.Callback, jsonPluggableLibrary); } }
internal static void CallCallbackForEachChannelEntity <T> (List <ChannelEntity> channelEntities, PubnubClientError clientError, PubnubErrorFilter.Level errorLevel) { foreach (ChannelEntity ce in channelEntities) { PubnubChannelCallback <T> channelCallback = ce.ChannelParams.Callbacks as PubnubChannelCallback <T>; if (channelCallback != null) { GoToCallback(clientError, channelCallback.ErrorCallback, errorLevel); } } }
internal static PubnubChannelCallback <T> GetPubnubChannelCallback <T>(Action <T> userCallback, Action <T> connectCallback, Action <PubnubClientError> errorCallback, Action <T> disconnectCallback, Action <T> wildcardPresenceCallback ) { PubnubChannelCallback <T> pubnubChannelCallbacks = new PubnubChannelCallback <T> (); pubnubChannelCallbacks.SuccessCallback = userCallback; pubnubChannelCallbacks.ConnectCallback = connectCallback; pubnubChannelCallbacks.ErrorCallback = errorCallback; pubnubChannelCallbacks.DisconnectCallback = disconnectCallback; pubnubChannelCallbacks.WildcardPresenceCallback = wildcardPresenceCallback; return(pubnubChannelCallbacks); }
internal static void SendConnectCallback <T> (IJsonPluggableLibrary jsonPluggableLibrary, List <object> connectResult, string channel, ResponseType type, SafeDictionary <PubnubChannelCallbackKey, object> channelCallbacks) { var callbackKey = GetPubnubChannelCallbackKey(channel, type); if (channelCallbacks.Count > 0 && channelCallbacks.ContainsKey(callbackKey)) { PubnubChannelCallback <T> currentPubnubCallback = channelCallbacks [callbackKey] as PubnubChannelCallback <T>; if (currentPubnubCallback != null && currentPubnubCallback.ConnectCallback != null) { PubnubCallbacks.GoToCallback <T> (connectResult, currentPubnubCallback.ConnectCallback, jsonPluggableLibrary); } } }
internal static void SendCallback <T>(IJsonPluggableLibrary jsonPluggableLibrary, ChannelEntity channelEntity, List <object> itemMessage, CallbackType callbackType) { PubnubChannelCallback <T> channelCallbacks = channelEntity.ChannelParams.Callbacks as PubnubChannelCallback <T>; if (channelCallbacks != null) { SendCallbackBasedOnType <T> (jsonPluggableLibrary, channelCallbacks, itemMessage, callbackType); } #if (ENABLE_PUBNUB_LOGGING) else { LoggingMethod.WriteToLog(string.Format("DateTime {0}, SendCallbacks3: channelCallbacks null", DateTime.Now.ToString()), LoggingMethod.LevelInfo); } #endif }
internal static void CallErrorCallback <T>(ChannelEntity channelEntity, string message, PubnubErrorCode errorCode, PubnubErrorSeverity severity, PubnubErrorFilter.Level errorLevel) { List <ChannelEntity> channelEntities = new List <ChannelEntity> (); channelEntities.Add(channelEntity); PubnubClientError clientError = Helpers.CreatePubnubClientError <T> (message, null, channelEntities, errorCode, severity); PubnubChannelCallback <T> channelCallback = channelEntity.ChannelParams.Callbacks as PubnubChannelCallback <T>; if (channelCallback != null) { #if (ENABLE_PUBNUB_LOGGING) LoggingMethod.WriteToLog(string.Format("DateTime {0}, CallErrorCallback calling GoToCallback: clientError={1} ", DateTime.Now.ToString(), clientError), LoggingMethod.LevelInfo); #endif GoToCallback(clientError, channelCallback.ErrorCallback, errorLevel); } }
internal static void SendCallbackBasedOnType <T>(IJsonPluggableLibrary jsonPluggableLibrary, PubnubChannelCallback <T> channelCallbacks, List <object> itemMessage, CallbackType callbackType) { if (callbackType.Equals(CallbackType.Connect)) { GoToCallback <T> (itemMessage, channelCallbacks.ConnectCallback, jsonPluggableLibrary); } else if (callbackType.Equals(CallbackType.Disconnect)) { GoToCallback <T> (itemMessage, channelCallbacks.DisconnectCallback, jsonPluggableLibrary); } else if (callbackType.Equals(CallbackType.Success)) { GoToCallback <T> (itemMessage, channelCallbacks.SuccessCallback, jsonPluggableLibrary); } else if (callbackType.Equals(CallbackType.Wildcard)) { GoToCallback <T> (itemMessage, channelCallbacks.WildcardPresenceCallback, jsonPluggableLibrary); } }