public override void ReadFrom(TarsInputStream _is) { sGuid = (string)_is.Read(sGuid, 0, false); iTime = (int)_is.Read(iTime, 1, false); vProxyList = (List <LiveProxyValue>)_is.Read(vProxyList, 2, false); iAccess = (int)_is.Read(iAccess, 3, false); }
/// <summary> /// 获取一个元素,tup新旧版本都兼容 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="Name"></param> /// <param name="DefaultObj"></param> /// <returns></returns> public T Get <T>(string Name, T DefaultObj, TarsInputStream inputStream) { try { object result = null;; if (IsPacketTypeTup3) { result = GetByClass <T>(Name, DefaultObj, inputStream); } else //tup2 { result = Get <T>(Name, inputStream); } if (result == null) { return(DefaultObj); } return((T)result); } catch { return(DefaultObj); } }
public void DecodeTup3(TarsInputStream inputStream, int Index = 0) { Version = Const.PacketTypeTup3; inputStream.SetServerEncoding(EncodeName); newData = new Dictionary <string, byte[]>(); inputStream.ReadMap <string, byte[]>(newData, 0, false); }
public override void ReadFrom(TarsInputStream _is) { lTid = (long)_is.Read(lTid, 0, false); lSid = (long)_is.Read(lSid, 1, false); iUserHeartBeatInterval = (int)_is.Read(iUserHeartBeatInterval, 2, false); iPresentHeartBeatInterval = (int)_is.Read(iPresentHeartBeatInterval, 3, false); }
/* * static public void Read(TarsInputStream _is, ref WebSocketCommand command, * int tag, bool require = true) * { * command = (WebSocketCommand)_is.Read(command, tag, require); * } * * static public void Write(TarsOutputStream _os, WebSocketCommand command, int tag) * { * _os.Write(command, tag); * } * //*/ public override void ReadFrom(TarsInputStream _is) { iCmdType = (int)_is.Read(iCmdType, 0, false); vData = (byte[])_is.Read(vData, 1, false); lRequestId = (long)_is.Read(lRequestId, 2, false); sTraceId = (string)_is.Read(sTraceId, 3, false); }
public override void ReadFrom(TarsInputStream _is) { iPropsIdType = (int)_is.Read(iPropsIdType, 1, false); sPropsPic18 = (string)_is.Read(sPropsPic18, 2, false); sPropsPic24 = (string)_is.Read(sPropsPic24, 3, false); sPropsPicGif = (string)_is.Read(sPropsPicGif, 4, false); sPropsBannerResource = (string)_is.Read(sPropsBannerResource, 5, false); sPropsBannerSize = (string)_is.Read(sPropsBannerSize, 6, false); sPropsBannerMaxTime = (string)_is.Read(sPropsBannerMaxTime, 7, false); sPropsChatBannerResource = (string)_is.Read(sPropsChatBannerResource, 8, false); sPropsChatBannerSize = (string)_is.Read(sPropsChatBannerSize, 9, false); sPropsChatBannerMaxTime = (string)_is.Read(sPropsChatBannerMaxTime, 10, false); iPropsChatBannerPos = (int)_is.Read(iPropsChatBannerPos, 11, false); iPropsChatBannerIsCombo = (int)_is.Read(iPropsChatBannerIsCombo, 12, false); sPropsRollContent = (string)_is.Read(sPropsRollContent, 13, false); iPropsBannerAnimationstyle = (int)_is.Read(iPropsBannerAnimationstyle, 14, false); sPropFaceu = (string)_is.Read(sPropFaceu, 15, false); sPropH5Resource = (string)_is.Read(sPropH5Resource, 16, false); sPropsWeb = (string)_is.Read(sPropsWeb, 17, false); iWitch = (int)_is.Read(iWitch, 18, false); sCornerMark = (string)_is.Read(sCornerMark, 19, false); iPropViewId = (int)_is.Read(iPropViewId, 20, false); sPropStreamerResource = (string)_is.Read(sPropStreamerResource, 21, false); iStreamerFrameRate = (short)_is.Read(iStreamerFrameRate, 22, false); sPropsPic108 = (string)_is.Read(sPropsPic108, 23, false); sPcBannerResource = (string)_is.Read(sPcBannerResource, 24, false); }
/** * 对传入的数据进行解码 填充可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) { try { iVersion = (short)_is.Read(iVersion, 1, true); cPacketType = (byte)_is.Read(cPacketType, 2, true); iMessageType = (int)_is.Read(iMessageType, 3, true); iRequestId = (int)_is.Read(iRequestId, 4, true); sServantName = (string)_is.ReadString(5, true); sFuncName = (string)_is.ReadString(6, true); if (cache_sBuffer == null) { cache_sBuffer = new byte[] { 0 }; } sBuffer = (byte[])_is.Read <byte[]>(cache_sBuffer, 7, true); iTimeout = (int)_is.Read(iTimeout, 8, true); Dictionary <string, string> cache_context = null; context = (Dictionary <string, string>)_is.Read <Dictionary <string, string> >(cache_context, 9, true); status = (Dictionary <string, string>)_is.Read <Dictionary <string, string> >(cache_context, 10, true); } catch (Exception ex) { QTrace.Trace(this + " ReadFrom Exception: " + ex.Message); throw ex; } }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); lBadgeId = (long)_is.Read(lBadgeId, 1, false); iBadgeLevel = (int)_is.Read(iBadgeLevel, 2, false); iScore = (int)_is.Read(iScore, 3, false); }
public override void ReadFrom(TarsInputStream _is) { tId = (UserId)_is.Read(tId, 0, false); lTopcid = (long)_is.Read(lTopcid, 1, false); lSubcid = (long)_is.Read(lSubcid, 2, false); sSendContent = (string)_is.Read(sSendContent, 3, false); }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); lPid = (long)_is.Read(lPid, 1, false); iGuardLevel = (int)_is.Read(iGuardLevel, 2, false); lEndTime = (long)_is.Read(lEndTime, 3, false); }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); lImid = (long)_is.Read(lImid, 1, false); sNickName = (string)_is.Read(sNickName, 2, false); iGender = (int)_is.Read(iGender, 3, false); }
public override void ReadFrom(TarsInputStream _is) { id = (int)_is.Read(id, 0, false); name = (string)_is.Read(name, 1, false); uids = (Dictionary <long, short>)_is.Read(uids, 2, false); tips = (string)_is.Read(tips, 3, false); }
public override void ReadFrom(TarsInputStream _is) { iPushType = (int)_is.Read(iPushType, 0, false); iUri = (int)_is.Read(iUri, 1, false); sMsg = (byte[])_is.Read(sMsg, 2, false); iProtocolType = (int)_is.Read(iProtocolType, 3, false); }
public override void ReadFrom(TarsInputStream _is) { vPropsItemList = (List <PropsItem>)_is.Read(vPropsItemList, 1, false); sMd5 = (string)_is.Read(sMd5, 2, false); iNewEffectSwitch = (short)_is.Read(iNewEffectSwitch, 3, false); iMirrorRoomShowNum = (short)_is.Read(iMirrorRoomShowNum, 4, false); iGameRoomShowNum = (short)_is.Read(iGameRoomShowNum, 5, false); }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); sGuid = (string)_is.Read(sGuid, 1, false); sToken = (string)_is.Read(sToken, 2, false); sHuyaUA = (string)_is.Read(sHuyaUA, 3, false); sCookie = (string)_is.Read(sCookie, 4, false); }
public override void ReadFrom(TarsInputStream _is) { iFontColor = (int)_is.Read(iFontColor, 0, false); iFontSize = (int)_is.Read(iFontSize, 1, false); iTextSpeed = (int)_is.Read(iTextSpeed, 2, false); iTransitionType = (int)_is.Read(iTransitionType, 3, false); iPopupStyle = (int)_is.Read(iPopupStyle, 4, false); }
private object DecodeBuffer(byte[] buffer, Type type) { TarsInputStream tis = new TarsInputStream(buffer); tis.SetServerEncoding(EncodeName); var result = tis.Read(type, 0, true); return(result); }
public override void ReadFrom(TarsInputStream _is) { tUserId = (UserId)_is.Read(tUserId, 1, false); sMd5 = (string)_is.Read(sMd5, 2, false); iTemplateType = (int)_is.Read(iTemplateType, 3, false); sVersion = (string)_is.Read(sVersion, 4, false); iAppId = (int)_is.Read(iAppId, 5, false); lPresenterUid = (long)_is.Read(lPresenterUid, 6, false); lSid = (long)_is.Read(lSid, 7, false); lSubSid = (long)_is.Read(lSubSid, 8, false); }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); bAonymous = (bool)_is.Read(bAonymous, 1, false); sGuid = (string)_is.Read(sGuid, 2, false); sToken = (string)_is.Read(sToken, 3, false); lTid = (long)_is.Read(lTid, 4, false); lSid = (long)_is.Read(lSid, 5, false); lGroupId = (long)_is.Read(lGroupId, 6, false); lGroupType = (long)_is.Read(lGroupType, 7, false); }
public virtual void DecodeResponse(TarsInputStream input, RequestPacket response) { response.PacketType = input.Read((byte)0, 2, true); response.RequestId = input.Read(0, 3, true); response.MessageType = input.Read(0, 4, true); response.Ret = input.Read(0, 5, true); response.Buffer = input.Read(new byte[0], 6, true); response.Status = input.ReadMap <string, string>(new Dictionary <string, string>(), 7, false); response.ResultDesc = input.ReadString(8, false); response.Context = input.ReadMap <string, string>(new Dictionary <string, string>(), 9, false); }
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 override void ReadFrom(TarsInputStream inputStream) { if (IsPacketTypeTup3) { newData = (Dictionary <string, byte[]>)inputStream.ReadMap(newData, 0, false); } else { data = (Dictionary <string, Dictionary <string, byte[]> >)inputStream.ReadMap(data, 0, false); } }
public override void ReadFrom(TarsInputStream _is) { lUid = (long)_is.Read(lUid, 0, false); lPid = (long)_is.Read(lPid, 1, false); lValidDate = (long)_is.Read(lValidDate, 2, false); sNobleName = (string)_is.Read(sNobleName, 3, false); iNobleLevel = (int)_is.Read(iNobleLevel, 4, false); iNoblePet = (int)_is.Read(iNoblePet, 5, false); iNobleStatus = (int)_is.Read(iNobleStatus, 6, false); iNobleType = (int)_is.Read(iNobleType, 7, false); iRemainDays = (int)_is.Read(iRemainDays, 8, false); }
public override void ReadFrom(TarsInputStream _is) { vDecorationPrefix = (List <DecorationInfo>)_is.Read(vDecorationPrefix, 0, false); vDecorationSuffix = (List <DecorationInfo>)_is.Read(vDecorationSuffix, 1, false); tFormat = (ContentFormat)_is.Read(tFormat, 2, false); tBulletFormat = (BulletFormat)_is.Read(tBulletFormat, 3, false); vForwardChannels = (List <ChannelPair>)_is.Read(vForwardChannels, 4, false); iModifyMask = (int)_is.Read(iModifyMask, 5, false); vBulletPrefix = (List <DecorationInfo>)_is.Read(vBulletPrefix, 6, false); tUserInfo = (SenderInfo)_is.Read(tUserInfo, 7, false); vBulletSuffix = (List <DecorationInfo>)_is.Read(vBulletSuffix, 8, false); }
public override void ReadFrom(TarsInputStream _is) { lStarterUid = (long)_is.Read(lStarterUid, 0, false); sStarterNick = (string)_is.Read(sStarterNick, 1, false); iShortChannelId = (long)_is.Read(iShortChannelId, 2, false); vAwardUsers = (List <AwardUser>)_is.Read(vAwardUsers, 3, false); lTid = (long)_is.Read(lTid, 4, false); lSid = (long)_is.Read(lSid, 5, false); iTreasureType = (long)_is.Read(iTreasureType, 6, false); sTreasureName = (string)_is.Read(sTreasureName, 7, false); lPid = (long)_is.Read(lPid, 8, false); }
/* * 测试 UniAttributte */ public void TestUnipack(TestInfo ti) { byte[] buffer = new byte[8192]; UniAttribute unipack = new UniAttribute(); short tests = -100; int testi = int.MaxValue; long testl = -1000; float testf = -100.032f; string teststr = "teststring"; // 设置 tup 版本号,默认是 tup2,非精简版. unipack.Version = Tup.Const.TUP_VERSION_2; unipack.Put("mystruct", ti); unipack.Put("tests", tests); unipack.Put("testi", testi); unipack.Put("testl", testl); unipack.Put("testf", testf); unipack.Put("teststr", teststr); buffer = unipack.Encode(); Console.WriteLine("buffer.size: " + buffer.Length); UniAttribute de = new UniAttribute(); TarsInputStream _is = new TarsInputStream(buffer); de.ReadFrom(_is); TestInfo st = new TestInfo(); short dtests = 0; int dtesti = 0; long dtestl = 0; float dtestf = 0.0f; string dteststr = ""; // 使用新的Get<T>(string Name, T DefaultObj) dtests = de.Get <short>("tests", dtests); dtesti = de.Get <int>("testi", dtesti); dtestl = de.Get <long>("testl", dtestl); dtestf = de.Get <float>("testf", dtestf); dteststr = de.Get <string>("teststr", dteststr); st = de.Get <TestInfo>("mystruct", st); Console.WriteLine("dtests: " + dtests); Console.WriteLine("dtesti: " + dtesti); Console.WriteLine("dtestl: " + dtestl); Console.WriteLine("dtestf: " + dtestf); Console.WriteLine("dteststr: " + dteststr); Console.WriteLine("\nTestInfo get struct: st->ibegin=" + st.ibegin + " st->li=" + st.li); Console_PressAnyKey(); }
public virtual void DecodeRequest(TarsInputStream input, RequestPacket request) { request.PacketType = input.Read(request.PacketType, 2, true); request.MessageType = input.Read(request.MessageType, 3, true); request.RequestId = input.Read(request.RequestId, 4, true); request.ServantName = input.ReadString(5, true); request.FuncName = input.ReadString(6, true); request.Buffer = input.ReadBytes(7, true); request.Timeout = input.Read(request.Timeout, 8, true); request.Context = input.ReadMap <string, string>(new Dictionary <string, string>(), 9, false); request.Status = input.ReadMap <string, string>(new Dictionary <string, string>(), 10, false); }
public override void DecodeResponse(TarsInputStream input, RequestPacket response) { response.PacketType = input.Read((byte)0, 2, true); response.MessageType = input.Read(0, 3, true); response.RequestId = input.Read(0, 4, true); response.ServantName = input.ReadString(5, true); response.FuncName = input.ReadString(6, true); response.Buffer = input.Read(new byte[0], 7, true); response.Timeout = input.Read(0, 8, true); response.Status = input.ReadMap <string, string>(new Dictionary <string, string>(), 9, false); response.Context = input.ReadMap <string, string>(new Dictionary <string, string>(), 10, false); response.GetRetToStatus(); }
public override void ReadFrom(TarsInputStream _is) { iItemType = (int)_is.Read(iItemType, 0, false); iItemCount = (int)_is.Read(iItemCount, 1, false); lSenderUid = (long)_is.Read(lSenderUid, 3, false); sSenderNick = (string)_is.Read(sSenderNick, 4, false); lPresenterUid = (long)_is.Read(lPresenterUid, 5, false); sPresenterNick = (string)_is.Read(sPresenterNick, 6, false); lSid = (long)_is.Read(lSid, 7, false); lSubSid = (int)_is.Read(lSubSid, 8, false); lRoomId = (int)_is.Read(lRoomId, 9, false); iTemplateType = (int)_is.Read(iTemplateType, 10, false); }