コード例 #1
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(lUid, 0);
     _os.Write(lPid, 1);
     _os.Write(lValidDate, 2);
     _os.Write(sNobleName, 3);
     _os.Write(iNobleLevel, 4);
     _os.Write(iNoblePet, 5);
     _os.Write(iNobleStatus, 6);
     _os.Write(iNobleType, 7);
     _os.Write(iRemainDays, 8);
 }
コード例 #2
0
 public virtual void EncodeRequest(TarsOutputStream output, RequestPacket request)
 {
     output.Write(request.Version, 1);
     output.Write(request.PacketType, 2);
     output.Write(request.MessageType, 3);
     output.Write(request.RequestId, 4);
     output.Write(request.ServantName, 5);
     output.Write(request.FuncName, 6);
     output.Write(request.Buffer, 7);
     output.Write(request.Timeout, 8);
     output.Write(request.Context, 9);
     output.Write(request.Status, 10);
 }
コード例 #3
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iItemType, 0);
     _os.Write(iItemCount, 1);
     _os.Write(lSenderUid, 3);
     _os.Write(sSenderNick, 4);
     _os.Write(lPresenterUid, 5);
     _os.Write(sPresenterNick, 6);
     _os.Write(lSid, 7);
     _os.Write(lSubSid, 8);
     _os.Write(lRoomId, 9);
     _os.Write(iTemplateType, 10);
 }
コード例 #4
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iVersion, 1);
     _os.Write(cPacketType, 2);
     _os.Write(iMessageType, 3);
     _os.Write(iRequestId, 4);
     _os.Write(sServantName, 5);
     _os.Write(sFuncName, 6);
     _os.Write(sBuffer, 7);
     _os.Write(iTimeout, 8);
     _os.Write(context, 9);
     _os.Write(status, 10);
 }
コード例 #5
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(tId, 0);
     _os.Write(lTid, 1);
     _os.Write(lSid, 2);
     _os.Write(lShortTid, 3);
     _os.Write(eOp, 4);
     _os.Write(sChan, 5);
     _os.Write(eSource, 6);
     _os.Write(lPid, 7);
     _os.Write(bWatchVideo, 8);
     _os.Write(bAnonymous, 9);
     _os.Write(eTemplateType, 10);
 }
コード例 #6
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(tId, 0);
     _os.Write(lTid, 1);
     _os.Write(lSid, 2);
     _os.Write(lShortTid, 3);
     _os.Write(lPid, 4);
     _os.Write(bWatchVideo, 5);
     _os.Write(iLineType, 6);
     _os.Write(iFps, 7);
     _os.Write(iAttendee, 8);
     _os.Write(iBandWidth, 9);
     _os.Write(iLastHeartElapseTime, 10);
 }
コード例 #7
0
ファイル: Tup2CodecHandler.cs プロジェクト: fs7744/Tars
 public override void EncodeResponse(TarsOutputStream output, RequestPacket response)
 {
     response.SetRetToStatus();
     output.Write(response.Version, 1);
     output.Write(response.PacketType, 2);
     output.Write(response.MessageType, 3);
     output.Write(response.RequestId, 4);
     output.Write(response.ServantName, 5);
     output.Write(response.FuncName, 5);
     output.Write(response.Buffer, 7);
     output.Write(response.Timeout, 8);
     output.Write(response.Status, 9);
     output.Write(response.Context, 10);
 }
コード例 #8
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iMarqueeScopeMin, 1);
     _os.Write(iMarqueeScopeMax, 2);
     _os.Write(iCurrentVideoNum, 3);
     _os.Write(iCurrentVideoMin, 4);
     _os.Write(iCurrentVideoMax, 5);
     _os.Write(iAllVideoNum, 6);
     _os.Write(iAllVideoMin, 7);
     _os.Write(iAllVideoMax, 8);
     _os.Write(iCurrentScreenNum, 9);
     _os.Write(iCurrentScreenMin, 10);
     _os.Write(iCurrentScreenMax, 11);
 }
コード例 #9
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iFirstSingle, 1);
     _os.Write(iFirstGroup, 2);
     _os.Write(sFirstTips, 3);
     _os.Write(iSecondSingle, 4);
     _os.Write(iSecondGroup, 5);
     _os.Write(sSecondTips, 6);
     _os.Write(iThirdSingle, 7);
     _os.Write(iThirdGroup, 8);
     _os.Write(sThirdTips, 9);
     _os.Write(iWorldSingle, 10);
     _os.Write(iWorldGroup, 11);
 }
コード例 #10
0
        /**
         * 放入一个元素
         * @param <T>
         * @param name
         * @param t
         */
        public void Put <T>(string name, T t)
        {
            if (name == null)
            {
                throw new ArgumentException("put key can not is null");
            }
            if (t == null)
            {
                throw new ArgumentException("put value can not is null");
            }

            TarsOutputStream _out = new TarsOutputStream();

            _out.setServerEncoding(_encodeName);
            _out.Write(t, 0);
            byte[] sBuffer = TarsUtil.getTarsBufArray(_out.getMemoryStream());

            if (_iVer == Const.PACKET_TYPE_TUP3)
            {
                cachedData.Remove(name);

                if (_new_data.ContainsKey(name))
                {
                    _new_data[name] = sBuffer;
                }
                else
                {
                    _new_data.Add(name, sBuffer);
                }
            }
            else
            {
                List <string> listType = new List <string>();
                CheckObjectType(listType, t);
                string className = BasicClassTypeUtil.TransTypeList(listType);

                Dictionary <string, byte[]> pair = new Dictionary <string, byte[]>(1);
                pair.Add(className, sBuffer);
                cachedData.Remove(name);

                if (_data.ContainsKey(name))
                {
                    _data[name] = pair;
                }
                else
                {
                    _data.Add(name, pair);
                }
            }
        }
コード例 #11
0
        /**
         * Put in an element.
         * @param <T>
         * @param name
         * @param value
         */
        public void Put <T>(string name, T value)
        {
            if (name == null)
            {
                throw new ArgumentException("put key can not is null");
            }
            if (value == null)
            {
                throw new ArgumentException("put value can not is null");
            }

            TarsOutputStream _out = new TarsOutputStream();

            _out.SetServerEncoding(_encodeName);
            _out.Write(value, 0);
            byte[] sBuffer = TarsUtil.GetTarsBufferArray(_out.GetMemoryStream());

            if (_iVer == Const.TUP_VERSION_3)
            {
                cachedData.Remove(name);
                if (_new_data.ContainsKey(name))
                {
                    _new_data[name] = sBuffer;
                }
                else
                {
                    _new_data.Add(name, sBuffer);
                }
            }
            else
            {
                List <string> listType = new List <string>();
                CheckObjectType(listType, value);
                string className = BasicClassTypeUtil.TransTypeList(listType);

                Dictionary <string, byte[]> map = new Dictionary <string, byte[]>(1);
                map.Add(className, sBuffer);
                cachedData.Remove(name);

                if (_data.ContainsKey(name))
                {
                    _data[name] = map;
                }
                else
                {
                    _data.Add(name, map);
                }
            }
        }
コード例 #12
0
        public byte[] Encode()
        {
            TarsOutputStream _os = new TarsOutputStream(0);

            _os.SetServerEncoding(_encodeName);
            if (_iVer == Const.TUP_VERSION_3)
            {
                _os.Write(_new_data, 0);
            }
            else
            {
                _os.Write(_data, 0);
            }
            return(TarsUtil.GetTarsBufferArray(_os.GetMemoryStream()));
        }
コード例 #13
0
        public virtual byte[] EncodeMethodParameters(object[] parameters, RpcMethodMetadata metdata)
        {
            if (metdata.Parameters.Length == 0)
            {
                return(new byte[0]);
            }
            var buf    = Unpooled.Buffer(128);
            var output = new TarsOutputStream(buf);

            foreach (var item in metdata.Parameters)
            {
                output.Write(parameters[item.Position], item.Position + 1);
            }
            return(output.ToByteArray());
        }
コード例 #14
0
        public byte[] Encode()
        {
            TarsOutputStream _os = new TarsOutputStream(0);

            _os.setServerEncoding(_encodeName);
            if (_iVer == Const.PACKET_TYPE_TUP3)
            {
                _os.Write(_new_data, 0);
            }
            else
            {
                _os.Write(_data, 0);
            }
            return(TarsUtil.getTarsBufArray(_os.getMemoryStream()));
        }
コード例 #15
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(lUid, 0);
     _os.Write(sNickName, 1);
     _os.Write(lPid, 2);
     _os.Write(tNobelInfo, 3);
     _os.Write(tGuardInfo, 4);
     _os.Write(tWeekRankInfo, 5);
     _os.Write(sAvatarUrl, 6);
     _os.Write(bFromNearby, 7);
     _os.Write(sLocation, 8);
     _os.Write(tDecorationInfo, 9);
     _os.Write(tWeekHeartStirRankInfo, 10);
     _os.Write(tWeekHeartBlockRankInfo, 11);
 }
コード例 #16
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(tUserInfo, 0);
     _os.Write(lTid, 1);
     _os.Write(lSid, 2);
     _os.Write(sContent, 3);
     _os.Write(iShowMode, 4);
     _os.Write(tFormat, 5);
     _os.Write(tBulletFormat, 6);
     _os.Write(iTermType, 7);
     _os.Write(vDecorationPrefix, 8);
     _os.Write(vDecorationSuffix, 9);
     _os.Write(vAtSomeone, 10);
     _os.Write(lPid, 11);
 }
コード例 #17
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(lUid, 0);
     _os.Write(sNickName, 1);
     _os.Write(iLevel, 2);
     _os.Write(sName, 3);
     _os.Write(iPet, 4);
     _os.Write(lPid, 5);
     _os.Write(lTid, 6);
     _os.Write(lSid, 7);
     _os.Write(lStartTime, 8);
     _os.Write(lEndTime, 9);
     _os.Write(iLeftDay, 10);
     _os.Write(iStatus, 11);
     _os.Write(iOpenFlag, 12);
 }
コード例 #18
0
        public byte[] Encode()
        {
            TarsOutputStream os = new TarsOutputStream();

            os.SetServerEncoding(EncodeName);
            if (IsVersionTup3)
            {
                os.Write((IDictionary)newData, 0);
                return(os.ToByteArray());
            }
            else
            {
                os.Write((IDictionary)data, 0);
                return(os.ToByteArray());
            }
        }
コード例 #19
0
        public void Put <T>(string name, T t)
        {
            if (name == null)
            {
                throw new ArgumentException("put key can not be null");
            }
            if (t == null)
            {
                throw new ArgumentException("put value can not be null");
            }
            TarsOutputStream _out = new TarsOutputStream();

            _out.SetServerEncoding(EncodeName);
            _out.Write(t, 0);
            byte[] sBuffer = _out.ToByteArray();
            if (IsVersionTup3)
            {
                if (newData.ContainsKey(name))
                {
                    newData[name] = sBuffer;
                }
                else
                {
                    newData.Add(name, sBuffer);
                }
            }
            else
            {
                List <string> listType = new List <string>();
                CheckObjectType(listType, t);
                string className = BasicClassTypeUtil.TransTypeList(listType);
                Dictionary <string, byte[]> pair = new Dictionary <string, byte[]>(1)
                {
                    { className, sBuffer }
                };
                cachedData.Remove(name);
                if (data.ContainsKey(name))
                {
                    data[name] = pair;
                }
                else
                {
                    data.Add(name, pair);
                }
            }
        }
コード例 #20
0
        public virtual byte[] EncodeReturnValue(object returnValue, object[] parameters, RpcMethodMetadata metdata)
        {
            var buf    = Unpooled.Buffer(128);
            var output = new TarsOutputStream(buf);

            if (metdata.RealReturnType != typeof(void))
            {
                output.Write(returnValue, 0);
            }
            if (parameters != null)
            {
                foreach (var item in metdata.Parameters.Where(i => i.ParameterType.IsByRef))
                {
                    output.Write(parameters[item.Position], item.Position + 1);
                }
            }
            return(output.ToByteArray());
        }
コード例 #21
0
        /**
         * 为兼容最早发布的客户端版本解码使用 iret字段始终为0
         *
         * @return
         */
        public byte[] CreateOldRespEncode()
        {
            TarsOutputStream _os = new TarsOutputStream(0);

            _os.setServerEncoding(EncodeName);
            _os.Write(_data, 0);
            byte[] oldSBuffer = TarsUtil.getTarsBufArray(_os.getMemoryStream());
            _os = new TarsOutputStream(0);
            _os.setServerEncoding(EncodeName);
            _os.Write(_package.iVersion, 1);
            _os.Write(_package.cPacketType, 2);
            _os.Write(_package.iRequestId, 3);
            _os.Write(_package.iMessageType, 4);
            _os.Write(OldRespIRet, 5);
            _os.Write(oldSBuffer, 6);
            _os.Write(_package.status, 7);
            return(TarsUtil.getTarsBufArray(_os.getMemoryStream()));
        }
コード例 #22
0
ファイル: Tup2CodecHandler.cs プロジェクト: fs7744/Tars
        public override byte[] EncodeReturnValue(object returnValue, object[] parameters, RpcMethodMetadata metdata)
        {
            var unaOut = CreateUniAttribute();

            if (returnValue != null && metdata.RealReturnType != typeof(void))
            {
                unaOut.Put(string.Empty, returnValue);
            }
            foreach (var item in metdata.Parameters.Where(i => i.ParameterType.IsByRef))
            {
                unaOut.Put(item.Name, parameters[item.Position]);
            }
            var buf    = Unpooled.Buffer(128);
            var output = new TarsOutputStream(buf);

            unaOut.WriteTo(output);
            return(output.ToByteArray());
        }
コード例 #23
0
ファイル: Tup2CodecHandler.cs プロジェクト: fs7744/Tars
        public override byte[] EncodeMethodParameters(object[] parameters, RpcMethodMetadata metdata)
        {
            if (metdata.Parameters.Length == 0)
            {
                return(new byte[0]);
            }
            var unaOut = CreateUniAttribute();

            foreach (var item in metdata.Parameters.Where(i => i.ParameterType.IsByRef))
            {
                unaOut.Put(item.Name, parameters[item.Position]);
            }
            var buf    = Unpooled.Buffer(128);
            var output = new TarsOutputStream(buf);

            unaOut.WriteTo(output);
            return(output.ToByteArray());
        }
コード例 #24
0
        /**
         * Encode the put object.
         */
        public new byte[] Encode()
        {
            if (_package.sServantName.Equals(""))
            {
                throw new ArgumentException("servantName can not is null");
            }
            if (_package.sFuncName.Equals(""))
            {
                throw new ArgumentException("funcName can not is null");
            }

            TarsOutputStream _os = new TarsOutputStream(0);

            _os.SetServerEncoding(EncodeName);
            if (_package.iVersion == Const.TUP_VERSION_2)
            {
                _os.Write(_data, 0);
            }
            else
            {
                _os.Write(_new_data, 0);
            }

            _package.sBuffer = TarsUtil.GetTarsBufferArray(_os.GetMemoryStream());

            _os = new TarsOutputStream(0);
            _os.SetServerEncoding(EncodeName);
            this.WriteTo(_os);

            byte[] bodys = TarsUtil.GetTarsBufferArray(_os.GetMemoryStream());
            int    size  = bodys.Length;

            MemoryStream stream = new MemoryStream(size + UniPacketHeadSize);

            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                // Entire packet length.
                writer.Write(ByteConverter.ReverseEndian(size + UniPacketHeadSize));
                writer.Write(bodys);
            }

            return(stream.ToArray());
        }
コード例 #25
0
        /**
         * 将put的对象进行编码
         */
        public new byte[] Encode()
        {
            if (_package.sServantName.Equals(""))
            {
                throw new ArgumentException("servantName can not is null");
            }
            if (_package.sFuncName.Equals(""))
            {
                throw new ArgumentException("funcName can not is null");
            }

            TarsOutputStream _os = new TarsOutputStream(0);

            _os.setServerEncoding(EncodeName);
            if (_package.iVersion == Const.PACKET_TYPE_TUP)
            {
                _os.Write(_data, 0);
            }
            else
            {
                _os.write(_new_data, 0);
            }

            _package.sBuffer = TarsUtil.getTarsBufArray(_os.getMemoryStream());

            _os = new TarsOutputStream(0);
            _os.setServerEncoding(EncodeName);
            this.WriteTo(_os);
            byte[] bodys = TarsUtil.getTarsBufArray(_os.getMemoryStream());
            int    size  = bodys.Length;

            MemoryStream ms = new MemoryStream(size + UniPacketHeadSize);

            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                // 整个数据包长度
                bw.Write(ByteConverter.ReverseEndian(size + UniPacketHeadSize));
                bw.Write(bodys);
            }

            return(ms.ToArray());
        }
コード例 #26
0
        public override void WriteTo(TarsOutputStream _os)
        {
            _os.Write(iPropsId, 1);
            _os.Write(sPropsName, 2);
            _os.Write(iPropsYb, 3);
            _os.Write(iPropsGreenBean, 4);
            _os.Write(iPropsWhiteBean, 5);
            _os.Write(iPropsGoldenBean, 6);
            _os.Write(iPropsRed, 7);
            _os.Write(iPropsPopular, 8);
            _os.Write(iPropsExpendNum, 9);
            _os.Write(iPropsFansValue, 10);

            _os.Write(vPropsNum, 11);
            _os.Write(iPropsMaxNum, 12);
            _os.Write(iPropsBatterFlag, 13);
            _os.Write(vPropsChannel, 14);
            _os.Write(sPropsToolTip, 15);
            _os.Write(vPropsIdentity, 16);
            _os.Write(iPropsWeights, 17);
            _os.Write(iPropsLevel, 18);
            _os.Write(tDisplayInfo, 19);
            _os.Write(tSpecialInfo, 20);

            _os.Write(iPropsGrade, 21);
            _os.Write(iPropsGroupNum, 22);
            _os.Write(sPropsCommBannerResource, 23);
            _os.Write(sPropsOwnBannerResource, 24);
            _os.Write(iPropsShowFlag, 25);
            _os.Write(iTemplateType, 26);
            _os.Write(iShelfStatus, 27);
            _os.Write(sAndroidLogo, 28);
            _os.Write(sIpadLogo, 29);
            _os.Write(sIphoneLogo, 30);

            _os.Write(sPropsCommBannerResourceEx, 31);
            _os.Write(sPropsOwnBannerResourceEx, 32);
            _os.Write(vPresenterUid, 33);
            _os.Write(vPropView, 34);
            _os.Write(iFaceUSwitch, 35);
        }
コード例 #27
0
 public virtual void EncodeResponse(TarsOutputStream output, RequestPacket response)
 {
     output.Write(response.Version, 1);
     output.Write(response.PacketType, 2);
     output.Write(response.RequestId, 3);
     output.Write(response.MessageType, 4);
     output.Write(response.Ret, 5);
     output.Write(response.Buffer, 6);
     if (response.Status != null)
     {
         output.Write(response.Status, 7);
     }
     if (response.Ret != Const.ServerSuccess)
     {
         output.Write(response.ResultDesc ?? "", 8);
     }
     if (response.Context != null)
     {
         output.Write(response.Context, 9);
     }
 }
コード例 #28
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iItemType, 0);
     _os.Write(strPayId, 1);
     _os.Write(iItemCount, 2);
     _os.Write(lPresenterUid, 3);
     _os.Write(lSenderUid, 4);
     _os.Write(sPresenterNick, 5);
     _os.Write(sSenderNick, 6);
     _os.Write(sSendContent, 7);
     _os.Write(iItemCountByGroup, 8);
     _os.Write(iItemGroup, 9);
     _os.Write(iSuperPupleLevel, 10);
     _os.Write(iComboScore, 11);
     _os.Write(iDisplayInfo, 12);
     _os.Write(iEffectType, 13);
     _os.Write(sSenderIcon, 14);
     _os.Write(sPresenterIcon, 15);
     _os.Write(iTemplateType, 16);
     _os.Write(sExpand, 17);
     _os.Write(bBusi, 18);
     _os.Write(iColorEffectType, 19);
 }
コード例 #29
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _os.Write(iItemType, 0);
     _os.Write(iItemCount, 1);
     _os.Write(lSenderSid, 2);
     _os.Write(lSenderUid, 3);
     _os.Write(sSenderNick, 4);
     _os.Write(lPresenterUid, 5);
     _os.Write(sPresenterNick, 6);
     _os.Write(lNoticeChannelCount, 7);
     _os.Write(iItemCountByGroup, 8);
     _os.Write(iItemGroup, 9);
     _os.Write(iDisplayInfo, 10);
     _os.Write(iSuperPupleLevel, 11);
     _os.Write(iTemplateType, 12);
     _os.Write(sExpand, 13);
     _os.Write(bBusi, 14);
     _os.Write(iShowTime, 15);
     _os.Write(lPresenterYY, 16);
     _os.Write(lSid, 17);
     _os.Write(lSubSid, 18);
     _os.Write(lRoomId, 19);
 }
コード例 #30
0
 public override void WriteTo(TarsOutputStream _os)
 {
     _package.WriteTo(_os);
 }