internal static void CheckResultListAndCallCallback <T>(List <object> result, Action <T> userCallback, IJsonPluggableLibrary jsonPluggableLibrary) { if (result != null && result.Count > 0) { PubnubCallbacks.GoToCallback <T> (result, userCallback, jsonPluggableLibrary); } }
internal static void ResponseCallbackErrorOrTimeoutHandler <T> (CustomEventArgs <T> cea, RequestState <T> requestState, string channel, PubnubErrorFilter.Level errorLevel, IJsonPluggableLibrary jsonPluggableLibrary) { WebException webEx = new WebException(cea.Message); if ((cea.Message.Contains("NameResolutionFailure") || cea.Message.Contains("ConnectFailure") || cea.Message.Contains("ServerProtocolViolation") || cea.Message.Contains("ProtocolError") )) { webEx = new WebException("Network connnect error", WebExceptionStatus.ConnectFailure); PubnubCallbacks.CallErrorCallback <T> (cea.Message, null, channel, PubnubErrorCode.NoInternetRetryConnect, PubnubErrorSeverity.Warn, requestState.ErrorCallback, errorLevel); } else if (cea.IsTimeout || Utility.CheckRequestTimeoutMessageInError(cea)) { } else if ((cea.Message.Contains("403")) || (cea.Message.Contains("java.io.FileNotFoundException")) || ((PubnubUnity.Version.Contains("UnityWeb")) && (cea.Message.Contains("Failed downloading")))) { PubnubClientError error = new PubnubClientError(403, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else if (cea.Message.Contains("500")) { PubnubClientError error = new PubnubClientError(500, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else if (cea.Message.Contains("502")) { PubnubClientError error = new PubnubClientError(503, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else if (cea.Message.Contains("503")) { PubnubClientError error = new PubnubClientError(503, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else if (cea.Message.Contains("504")) { PubnubClientError error = new PubnubClientError(504, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else if (cea.Message.Contains("414")) { PubnubClientError error = new PubnubClientError(414, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } else { PubnubClientError error = new PubnubClientError(400, PubnubErrorSeverity.Critical, cea.Message, PubnubMessageSource.Server, requestState.Request, requestState.Response, cea.Message, channel); PubnubCallbacks.GoToCallback(error, requestState.ErrorCallback, jsonPluggableLibrary); } ProcessResponseCallbackWebExceptionHandler <T> (webEx, requestState, channel, errorLevel); }
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); } } }