예제 #1
0
        void IManager.OnTransportError(ITransport trans, string err)
        {
            (this as IManager).EmitError(SocketIOErrors.Internal, err);

            if (trans.State == TransportStates.Connecting ||
                trans.State == TransportStates.Opening)
            {
#if !BESTHTTP_DISABLE_WEBSOCKET
                if (trans is WebSocketTransport)
                {
                    trans.Close();

                    // try to fall back
                    Transport = new PollingTransport(this);
                    Transport.Open();
                }
                else // fallback failed
#endif
                (this as IManager).TryToReconnect();
            }
            else
            {
                trans.Close();
                (this as IManager).TryToReconnect();
            }
        }
예제 #2
0
        /// <summary>
        /// Creates and starts opening/upgrading process of the transports.
        /// </summary>
        private void CreateTransports()
        {
            bool hasWSSupport = Handshake.Upgrades.Contains("websocket");

            if (hasWSSupport)
            {
                Transport = new WebSocketTransport(this);
            }

            Poller = new PollingTransport(this);
            Poller.Open();

            if (Transport == null)
            {
                Transport = Poller as ITransport;
            }
            else
            {
                Transport.Open();
            }
        }
예제 #3
0
 void IManager.OnTransportError(ITransport trans, string err)
 {
     ((IManager)this).EmitError(SocketIOErrors.Internal, err);
     if (trans.State == TransportStates.Connecting || trans.State == TransportStates.Opening)
     {
         if (trans is WebSocketTransport)
         {
             trans.Close();
             Transport = new PollingTransport(this);
             Transport.Open();
         }
         else
         {
             ((IManager)this).TryToReconnect();
         }
     }
     else
     {
         trans.Close();
         ((IManager)this).TryToReconnect();
     }
 }