Example #1
0
 public PubnubClientError(int statusCode, PubnubErrorSeverity errorSeverity, string message, PubnubMessageSource source, PubnubWebRequest pubnubWebRequest, PubnubWebResponse pubnubWebResponse, string description, string channel)
 {
     _dateTimeGMT             = DateTime.Now.ToUniversalTime();
     _statusCode              = statusCode;
     _isDotNetException       = false;
     _message                 = message;
     _errorSeverity           = errorSeverity;
     _messageSource           = source;
     _channel                 = channel;
     _detailedDotNetException = null;
     _pubnubWebRequest        = pubnubWebRequest;
     _pubnubWebResponse       = pubnubWebResponse;
     _description             = description;
 }
Example #2
0
 public RequestState(RequestState <T> requestState)
 {
     ErrorCallback     = requestState.ErrorCallback;
     ChannelEntities   = requestState.ChannelEntities;
     Reconnect         = requestState.Reconnect;
     Request           = requestState.Request;
     Response          = requestState.Response;
     Timeout           = requestState.Timeout;
     Timetoken         = requestState.Timetoken;
     TypeParameterType = requestState.TypeParameterType;
     SuccessCallback   = requestState.SuccessCallback as Action <T>;
     ID       = requestState.ID;
     RespType = requestState.RespType;
 }
Example #3
0
        protected override PubnubWebRequest SetProxy <T> (PubnubWebRequest request)
        {
#if (!SILVERLIGHT && !WINDOWS_PHONE)
            if (pubnubEnableProxyConfig && _pubnubProxy != null)
            {
                LoggingMethod.WriteToLog(string.Format("DateTime {0}, ProxyServer={1}; ProxyPort={2}; ProxyUserName={3}", DateTime.Now.ToString(), _pubnubProxy.ProxyServer, _pubnubProxy.ProxyPort, _pubnubProxy.ProxyUserName), LoggingMethod.LevelInfo);
                WebProxy webProxy = new WebProxy(_pubnubProxy.ProxyServer, _pubnubProxy.ProxyPort);
                webProxy.Credentials = new NetworkCredential(_pubnubProxy.ProxyUserName, _pubnubProxy.ProxyPassword);
                request.Proxy        = webProxy;
            }
#endif
            //No proxy setting for WP7
            return(request);
        }
Example #4
0
 public RequestState(RequestState <T> requestState)
 {
     Channels = requestState.Channels;
     #if (ENABLE_PUBNUB_LOGGING)
     LoggingMethod.WriteToLog(string.Format("DateTime {0}, Channels {1}", DateTime.Now.ToString(), Channels.ToString()), LoggingMethod.LevelInfo);
     #endif
     ConnectCallback   = requestState.ConnectCallback as Action <T>;
     ErrorCallback     = requestState.ErrorCallback;
     Reconnect         = requestState.Reconnect;
     Request           = requestState.Request;
     Response          = requestState.Response;
     Timeout           = requestState.Timeout;
     Timetoken         = requestState.Timetoken;
     TypeParameterType = requestState.TypeParameterType;
     UserCallback      = requestState.UserCallback as Action <T>;
     ID       = requestState.ID;
     RespType = requestState.RespType;
 }
Example #5
0
 protected override sealed void SendRequestAndGetResult <T> (Uri requestUri, RequestState <T> pubnubRequestState, PubnubWebRequest request)
 {
     if ((pubnubRequestState.Type == ResponseType.Publish) && (RequestIsUnsafe(requestUri)))
     {
         SendRequestUsingTcpClient <T> (requestUri, pubnubRequestState);
     }
     else
     {
         IAsyncResult asyncResult = request.BeginGetResponse(new AsyncCallback(UrlProcessResponseCallback <T>), pubnubRequestState);
         if (!asyncResult.AsyncWaitHandle.WaitOne(GetTimeoutInSecondsForResponseType(pubnubRequestState.Type) * 1000))
         {
             OnPubnubWebRequestTimeout <T> (pubnubRequestState, true);
         }
     }
 }
Example #6
0
 protected override PubnubWebRequest SetTimeout <T> (RequestState <T> pubnubRequestState, PubnubWebRequest request)
 {
     request.Timeout = GetTimeoutInSecondsForResponseType(pubnubRequestState.Type) * 1000;
     return(request);
 }
Example #7
0
 protected override PubnubWebRequest SetServicePointSetTcpKeepAlive(PubnubWebRequest request)
 {
     //do nothing for mono
     return(request);
 }
Example #8
0
 public PubnubClientError(int statusCode, PubnubErrorSeverity errorSeverity, string message,
                          PubnubMessageSource source, PubnubWebRequest pubnubWebRequest, PubnubWebResponse pubnubWebResponse, string description,
                          List <ChannelEntity> channelEntitles)
     : this(statusCode, errorSeverity, false, message, null, source, pubnubWebRequest, pubnubWebResponse, description, channelEntitles)
 {
 }
Example #9
0
 public PubnubClientError(int statusCode, PubnubErrorSeverity errorSeverity, bool isDotNetException, string message,
                          Exception detailedDotNetException, PubnubMessageSource source, PubnubWebRequest pubnubWebRequest,
                          PubnubWebResponse pubnubWebResponse, string description, List <ChannelEntity> channelEntitles)
     : this(statusCode, errorSeverity, isDotNetException, message, detailedDotNetException, source, pubnubWebRequest,
            pubnubWebResponse, description, Helpers.GetNamesFromChannelEntities(channelEntitles, false),
            Helpers.GetNamesFromChannelEntities(channelEntitles, true))
 {
 }
Example #10
0
        protected override sealed void SendRequestAndGetResult <T> (Uri requestUri, RequestState <T> pubnubRequestState, PubnubWebRequest request)
        {
#if (SILVERLIGHT || WINDOWS_PHONE)
            //For WP7, Ensure that the RequestURI length <= 1599
            //For SL, Ensure that the RequestURI length <= 1482 for Large Text Message. If RequestURI Length < 1343, Successful Publish occurs
            IAsyncResult asyncResult     = request.BeginGetResponse(new AsyncCallback(UrlProcessResponseCallback <T>), pubnubRequestState);
            Timer        webRequestTimer = new Timer(OnPubnubWebRequestTimeout <T>, pubnubRequestState, GetTimeoutInSecondsForResponseType(pubnubRequestState.Type) * 1000, Timeout.Infinite);
#else
            IAsyncResult asyncResult = request.BeginGetResponse(new AsyncCallback(UrlProcessResponseCallback <T>), pubnubRequestState);
            ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(OnPubnubWebRequestTimeout <T>), pubnubRequestState, GetTimeoutInSecondsForResponseType(pubnubRequestState.Type) * 1000, true);
#endif
            if (pubnubRequestState.Type == ResponseType.Presence || pubnubRequestState.Type == ResponseType.Subscribe)
            {
                if (presenceHeartbeatTimer != null)
                {
                    presenceHeartbeatTimer.Dispose();
                    presenceHeartbeatTimer = null;
                }
                if (pubnubRequestState.Channels != null && pubnubRequestState.Channels.Length > 0 && pubnubRequestState.Channels.Where(s => s.Contains("-pnpres") == false).ToArray().Length > 0)
                {
                    RequestState <T> presenceHeartbeatState = new RequestState <T>();
                    presenceHeartbeatState.Channels      = pubnubRequestState.Channels;
                    presenceHeartbeatState.Type          = ResponseType.PresenceHeartbeat;
                    presenceHeartbeatState.ErrorCallback = pubnubRequestState.ErrorCallback;
                    presenceHeartbeatState.Request       = null;
                    presenceHeartbeatState.Response      = null;

                    if (base.PresenceHeartbeatInterval > 0)
                    {
                        presenceHeartbeatTimer = new Timer(OnPresenceHeartbeatIntervalTimeout <T>, presenceHeartbeatState, base.PresenceHeartbeatInterval * 1000, base.PresenceHeartbeatInterval * 1000);
                    }
                }
            }
        }
Example #11
0
        protected override PubnubWebRequest SetTimeout <T>(RequestState <T> pubnubRequestState, PubnubWebRequest request)
        {
#if (!SILVERLIGHT && !WINDOWS_PHONE)
            request.Timeout = GetTimeoutInSecondsForResponseType(pubnubRequestState.Type) * 1000;
#endif
            //No Timeout setting for WP7
            return(request);
        }