public void TestGetPubnubChannelCallbackKey() { string channel = "testchannel"; ResponseType respType = ResponseType.Subscribe; PubnubChannelCallbackKey callbackKey = new PubnubChannelCallbackKey(); callbackKey.Channel = channel; callbackKey.Type = respType; PubnubChannelCallbackKey callbackKey2 = PubnubCallbacks.GetPubnubChannelCallbackKey(channel, respType); Assert.IsTrue(callbackKey.Channel.Equals(callbackKey2.Channel) && callbackKey.Type.Equals(callbackKey2.Type)); }
internal static SafeDictionary <PubnubChannelCallbackKey, object> CreateChannelCallbacks <T>(string[] channels, ResponseType responseType, Action <T> userCallback, Action <T> connectCallback, Action <PubnubClientError> errorCallback) { SafeDictionary <PubnubChannelCallbackKey, object> channelCallbacks = new SafeDictionary <PubnubChannelCallbackKey, object> (); foreach (string channel in channels) { PubnubChannelCallbackKey callbackKey = new PubnubChannelCallbackKey(); callbackKey.Channel = channel; callbackKey.Type = responseType; PubnubChannelCallback <T> pubnubChannelCallbacks = new PubnubChannelCallback <T> (); pubnubChannelCallbacks.Callback = userCallback; pubnubChannelCallbacks.ConnectCallback = connectCallback; pubnubChannelCallbacks.ErrorCallback = errorCallback; channelCallbacks.AddOrUpdate(callbackKey, pubnubChannelCallbacks, (key, oldValue) => pubnubChannelCallbacks); } return(channelCallbacks); }
public void TestResponseCallbackWebExceptionHandlerCommon <T>(string message, string[] channels, bool resumeOnReconnect, ResponseType responseType, CurrentRequestType crt, Action <T> userCallback, Action <T> connectCallback, Action <PubnubClientError> errorCallback, bool isTimeout, bool isError, long timetoken, bool ssl, PubnubErrorFilter.Level errorLevel ) { ExceptionMessage = message; ExceptionChannel = string.Join(",", channels); if (isTimeout) { ExceptionMessage = "Operation Timeout"; IsTimeout = true; } else { IsTimeout = false; } if (isError) { IsError = true; } else { IsError = false; } RequestState <T> requestState = BuildRequests.BuildRequestState <T> (channels, responseType, resumeOnReconnect, userCallback, connectCallback, errorCallback, 0, isTimeout, timetoken, typeof(T)); CustomEventArgs <T> cea = new CustomEventArgs <T> (); cea.PubnubRequestState = requestState; cea.Message = message; cea.IsError = isError; cea.IsTimeout = isTimeout; cea.CurrRequestType = crt; CRequestType = responseType; if (responseType == ResponseType.Presence || responseType == ResponseType.Subscribe) { ExceptionHandlers.MultiplexException += HandleMultiplexException <T>; resultPart1 = false; } WebException webEx = new WebException("Test web exception"); SafeDictionary <PubnubChannelCallbackKey, object> channelCallbacks = new SafeDictionary <PubnubChannelCallbackKey, object> (); PubnubChannelCallbackKey callbackKey = new PubnubChannelCallbackKey(); callbackKey.Channel = ExceptionChannel; callbackKey.Type = responseType; PubnubChannelCallback <T> pubnubChannelCallbacks = new PubnubChannelCallback <T>(); pubnubChannelCallbacks.Callback = userCallback; pubnubChannelCallbacks.ConnectCallback = connectCallback; pubnubChannelCallbacks.ErrorCallback = errorCallback; channelCallbacks.AddOrUpdate(callbackKey, pubnubChannelCallbacks, (key, oldValue) => pubnubChannelCallbacks); ExceptionHandlers.ResponseCallbackWebExceptionHandler <T> (cea, requestState, webEx, ExceptionChannel, channelCallbacks, errorLevel); /*if (responseType == ResponseType.Presence || responseType == ResponseType.Subscribe) { * DateTime dt = DateTime.Now; * while (dt.AddSeconds(2) > DateTime.Now) { * UnityEngine.Debug.Log ("waiting"); * } * }*/ }