/** * 对传入的数据进行解码 填充可get的对象 */ public new void Decode(byte[] buffer, int Index = 0) { if (buffer.Length < UniPacketHeadSize) { throw new ArgumentException("Decode namespace must include size head"); } try { TarsInputStream _is = new TarsInputStream(buffer, UniPacketHeadSize + Index); _is.setServerEncoding(EncodeName); //解码出RequestPacket包 this.ReadFrom(_is); //设置tup版本 _iVer = _package.iVersion; _is = new TarsInputStream(_package.sBuffer); _is.setServerEncoding(EncodeName); if (_package.iVersion == Const.PACKET_TYPE_TUP) { _data = (Dictionary <string, Dictionary <string, byte[]> >)_is.readMap <Dictionary <string, Dictionary <string, byte[]> > >(0, false); } else { _new_data = (Dictionary <string, byte[]>)_is.readMap <Dictionary <string, byte[]> >(0, false); } } catch (Exception e) { QTrace.Trace(this + " Decode Exception: " + e.Message); throw (e); } }
public override void ReadFrom(TarsInputStream _is) { if (_iVer == Const.PACKET_TYPE_TUP3) { _new_data = (Dictionary <string, byte[]>)_is.readMap <Dictionary <string, byte[]> >(_new_data, 0, false); } else { _data = (Dictionary <string, Dictionary <string, byte[]> >)_is.readMap <Dictionary <string, Dictionary <string, byte[]> > >(_data, 0, false); } }
public void Decode(byte[] buffer, int Index = 0) { try { //try tup2 _is.wrap(buffer, Index); _is.setServerEncoding(_encodeName); _iVer = Const.PACKET_TYPE_TUP; _data = (Dictionary <string, Dictionary <string, byte[]> >)_is.readMap <Dictionary <string, Dictionary <string, byte[]> > >(_data, 0, false); return; }catch { //try tup3 _iVer = Const.PACKET_TYPE_TUP3; _is.wrap(buffer, Index); _is.setServerEncoding(_encodeName); _new_data = (Dictionary <string, byte[]>)_is.readMap <Dictionary <string, byte[]> >(_new_data, 0, false); } }