Example #1
0
        public static bool receive(List <Connector.RawPackBody> listPack)
        {
            byte[] outBuf = null;
            int    offset = 0;
            int    count  = 0;

            if (!receiveFromSocket(ref outBuf, ref offset, ref count))
            {
                return(false);
            }
            byte[] outBody = null;
            int    outSeq  = 0;
            int    outCmd  = 0;

            if (!onReadSocket(outBuf, count, ref outBody, ref outSeq, ref outCmd))
            {
                return(false);
            }
            Connector.RawPackBody item = new Connector.RawPackBody {
                body = outBody,
                cmd  = outCmd,
                seq  = outSeq
            };
            //string aa = Util.byteToHexStr(outBuf);
            listPack.Add(item);
            return(true);
        }
Example #2
0
 public static bool receiveList(List <Connector.RawPackBody> listPack)
 {
     SessionPackMgr.getPackWithHttpClient(delegate(SessionPack sessionPack) {
         int seq           = 0;
         byte[] outBuf     = null;
         string cmdUri     = null;
         SocketError error = sessionPack.mHttpClient.receive(ref outBuf, ref seq, ref cmdUri);
         if (error == ((SocketError)((int)SocketError.NoData)))
         {
             return(false);
         }
         if (error == ((SocketError)((int)SocketError.SocketError)))
         {
             sessionPack.mHttpClient.close();
             sessionPack.mHttpClient = null;
             return(false);
         }
         if (((outBuf == null) || (outBuf.Length < 2)))
         {
             Log.e("Network", "received invalid reponse body, seq = " + seq);
             sessionPack.mHttpClient.close();
             sessionPack.mHttpClient = null;
             return(false);
         }
         Connector.RawPackBody item = new Connector.RawPackBody {
             body = outBuf,
             cmd  = sessionPack.mCmdID,
             seq  = seq
         };
         listPack.Add(item);
         mFailedCount = 0;
         sessionPack.mHttpClient.close();
         sessionPack.mHttpClient = null;
         HostService.mShortConnHosts.onCurrentHostSuccess();
         return(true);
     });
     return(true);
 }