Ejemplo n.º 1
0
 public static void close()
 {
     Log.i("Network", "close connector. ");
     LongConnector.close();
     ShortConnector.close();
     onPrepareSend(false);
 }
Ejemplo n.º 2
0
        public static bool isValidforPack(SessionPack sessionPack)
        {
            if (!LongConnector.isAvailable())
            {
                sessionPack.mConnectMode     = 2;
                sessionPack.mCacheBodyBuffer = null;
            }
            int mConnectMode = sessionPack.mConnectMode;

            if (mConnectMode == 1)
            {
                return(LongConnector.isValid());
            }
            if (mConnectMode != 2)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(sessionPack.mCmdUri))
            {
                Log.e("Network", "Cannot send pack via http without uri,  will been cancelled. seq= " + sessionPack.mSeqID);
                sessionPack.mCanceled = true;
                return(false);
            }
            return(ShortConnector.isValid());
        }
Ejemplo n.º 3
0
 public static void checkReady()
 {
     checkConnectStatus();
     checkNeedKeepAliveInShortConn(60000.0);
     LongConnector.checkReady();
     ShortConnector.checkReady();
 }
Ejemplo n.º 4
0
 public static void onPrepareSend(bool needCheckAlive)
 {
     NetHandler.startup();
     LongConnector.onPrepare();
     ShortConnector.onPrepare();
     if (needCheckAlive)
     {
         checkNeedKeepAliveInShortConn(0.0);
     }
 }
Ejemplo n.º 5
0
 public static List <RawPackBody> receiveBodyList()
 {
     mListRecvPack.Clear();
     LongConnector.receive(mListRecvPack);
     ShortConnector.receiveList(mListRecvPack);
     if (mListRecvPack.Count > 0)
     {
         mLastActiveTimestamp = SessionPack.getNow();
     }
     return(mListRecvPack);
 }
Ejemplo n.º 6
0
 public static void onSendFailed(bool needReconnect, int connMode)
 {
     if ((connMode & 1) != 0)
     {
         LongConnector.onSendFailed(needReconnect);
     }
     if ((connMode & 2) != 0)
     {
         ShortConnector.onSendFailed(needReconnect);
     }
 }
Ejemplo n.º 7
0
        public static bool sendPack(SessionPack sessionPack)
        {
            mLastActiveTimestamp = SessionPack.getNow();
            switch (sessionPack.mConnectMode)
            {
            case 1:
                return(LongConnector.sendPack(sessionPack));

            case 2:
                return(ShortConnector.sendPack(sessionPack));
            }
            return(true);
        }
Ejemplo n.º 8
0
 private static void checkNeedKeepAliveInShortConn(double interval)
 {//NetworkDeviceWatcher.isNetworkAvailable() &&
     if ((!LongConnector.isAvailable()) && ShortConnector.isValid())
     {
         double num = Util.getNowMilliseconds();
         if (mLastShortKeepAliveTimestamp == 0.0)
         {
             mLastShortKeepAliveTimestamp = num;
         }
         if (num >= (mLastShortKeepAliveTimestamp + interval))
         {
             Log.i("Network", "need keep alive in short connnector mode, post event to sync.");
             EventCenter.postEvent(EventConst.ON_NETSCENE_NOTIFY_SYNC_REQ, null, null);
             mLastShortKeepAliveTimestamp = num;
         }
     }
 }
Ejemplo n.º 9
0
 private static void checkConnectStatus()
 {
     //if (!NetworkDeviceWatcher.isNetworkAvailable())
     //{
     //    setConnectorStatus(ConntectorStatus.Disconnect);
     //}
     //else
     if (!LongConnector.isAvailable() || (mConnectorStatus == ConntectorStatus.Disconnect))
     {
         if (ShortConnector.isAvailable())
         {
             setConnectorStatus(ConntectorStatus.Connected);
         }
         else
         {
             setConnectorStatus(ConntectorStatus.Disconnect);
         }
     }
 }