当前位置: 首页>>代码示例>>C#>>正文


C# bnet.GetAttribute方法代码示例

本文整理汇总了C#中bnet.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# bnet.GetAttribute方法的具体用法?C# bnet.GetAttribute怎么用?C# bnet.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bnet的用法示例。


在下文中一共展示了bnet.GetAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessClientRequest

        public override void ProcessClientRequest(IRpcController controller, bnet.protocol.game_utilities.ClientRequest request, Action<bnet.protocol.game_utilities.ClientResponse> done)
        {
            var MessageId = request.GetAttribute(1).Value.IntValue;
            Logger.Trace("ProcessClientRequest() ID: {0}", MessageId);

            var builder = bnet.protocol.game_utilities.ClientResponse.CreateBuilder();

            //var version = request.GetAttribute(0).Value.StringValue; //0.5.1
            var attr = bnet.protocol.attribute.Attribute.CreateBuilder();
            switch (MessageId)
            {
                case 0: //D3.GameMessage.HeroDigestListRequest -> D3.GameMessage.HeroDigestListResponse
                    var digestList = GetHeroDigestList(D3.GameMessage.HeroDigestListRequest.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(digestList).Build());
                    break;
                case 1: //D3.GameMessage.GetAccountDigest -> D3.Account.Digest
                    var accountDigest = GetAccountDigest();
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(accountDigest).Build());
                    break;
                case 2: //CreateHero() -> D3.OnlineService.EntityId
                    var newToon = CreateHero(D3.OnlineService.HeroCreateParams.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(newToon).Build());
                    break;
                case 3: //D3.OnlineService.EntityId -> ?          Why have D3.GameMessage.DeleteHero and not use it?
                    var deleteToon = DeleteHero(D3.OnlineService.EntityId.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    //attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(deleteToon).Build());
                    break;
                case 4: //SelectToon() -> D3.OnlineService.EntityId
                    var selectToon = SelectHero(D3.OnlineService.EntityId.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    //attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(selectToon).Build());
                    break;
                case 5: //D3.GameMessages.SaveBannerConfiguration -> return MessageId with no Message
                    SaveBanner(D3.GameMessage.SaveBannerConfiguration.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    var attrId = bnet.protocol.attribute.Attribute.CreateBuilder()
                        .SetName("CustomMessageId")
                        .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(5).Build())
                        .Build();
                    builder.AddAttribute(attrId);
                    break;
                case 7: // Client doesn't care what you send here
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    break;
                case 8: //D3.GameMessage.SetGameAccountSettings ->
                    var setAccountSettings = SetGameAccountSettings(D3.GameMessage.SetGameAccountSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(setAccountSettings).Build());
                    break;
                case 9: //D3.GameMessage.GetToonSettings? -> D3.Client.ToonSettings
                    var getToonSettings = GetToonSettings(D3.GameMessage.GetToonSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getToonSettings).Build());
                    break;
                case 10: //D3.GameMessage.SetToonSettings?
                    var setToonSettings = SetToonSettings(D3.GameMessage.SetToonSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(setToonSettings).Build());
                    break;
                case 12: //D3.GameMessage.GetHeroItems
                    var heroItems = GetHeroItems(D3.GameMessage.GetHeroItems.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(heroItems).Build());
                    break;
                case 13: //D3.GameMessage.GetAccountItems
                    var accountItems = GetAccountItems(D3.GameMessage.GetAccountItems.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(accountItems).Build());
                    break;
                case 14: //D3.GameMessage.GetAccountProfile -> D3.Profile.AccountProfile
                    var getAccountProfile = GetAccountProfile(D3.GameMessage.GetAccountProfile.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getAccountProfile).Build());
                    break;
                case 15: //D3.GameMessage.GetHeroProfiles -> D3.Profile.HeroProfileList
                    var getHeroProfiles = GetHeroProfiles(D3.GameMessage.GetHeroProfiles.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getHeroProfiles).Build());
                    break;
                case 16: //? - Client expecting D3.Client.Preferences
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(D3.Client.Preferences.CreateBuilder().SetVersion(106).Build().ToByteString()).Build());
                    break;
                case 19: //D3.GameMessage.GetHeroIds -> D3.Hero.HeroList
                    var HeroList = GetHeroList(D3.GameMessage.GetHeroIds.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(HeroList).Build());
                    break;
                default:
                    Logger.Warn("Unknown CustomMessageId {0}: {1}", MessageId, request.AttributeCount > 2 ? request.GetAttribute(2).Value.ToString() : "No CustomMessage?");
                    break;
            }
            if (attr.HasValue)
            {
                attr.SetName("CustomMessage");
                builder.AddAttribute(attr.Build());
            }

            done(builder.Build());
        }
开发者ID:ElCorpseMaker,项目名称:mooege,代码行数:89,代码来源:GameUtilitiesService.cs

示例2: ProcessClientRequest

        public override void ProcessClientRequest(IRpcController controller, bnet.protocol.game_utilities.ClientRequest request, Action<bnet.protocol.game_utilities.ClientResponse> done)
        {
            var MessageId = request.GetAttribute(1).Value.IntValue;
            Logger.Trace("ProcessClientRequest() ID: {0}", MessageId);

            var builder = bnet.protocol.game_utilities.ClientResponse.CreateBuilder();

            //var version = request.GetAttribute(0).Value.StringValue; //0.5.1
            var attr = bnet.protocol.attribute.Attribute.CreateBuilder();
            switch (MessageId)
            {
                case 0: // unknown? - beta client was using this for D3.GameMessage.HeroDigestListRequest -> D3.GameMessage.HeroDigestListResponse but retail doesn't seem to so. /raist                    
                    /* beta client code 
                     * var digestList = GetHeroDigestList(D3.GameMessage.HeroDigestListRequest.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                     * attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(digestList).Build());
                     */
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    // client error; ERROR: >>> (no hero selected) BnetGameAccount::HeroCreate_OnReceivedHeroDigests no hero digests resolved for createdHeroEntityId={ high: 0 low: 5 }
                    break;
                case 1: //D3.GameMessage.GetAccountDigest -> D3.Account.Digest
                    var accountDigest = GetAccountDigest();
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(accountDigest).Build());
                    break;
                case 2: //CreateHero() -> D3.OnlineService.EntityId
                    var newToon = CreateHero(D3.OnlineService.HeroCreateParams.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(newToon).Build());
                    break;
                case 3: //D3.OnlineService.EntityId -> No return        Why have D3.GameMessage.DeleteHero and not use it?
                    DeleteHero(D3.OnlineService.EntityId.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    break;
                case 4: //SelectToon() -> D3.OnlineService.EntityId
                    var selectToon = SelectHero(D3.OnlineService.EntityId.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    //attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(selectToon).Build());
                    break;
                case 5: //D3.GameMessages.SaveBannerConfiguration -> return MessageId with no Message
                    SaveBanner(D3.GameMessage.SaveBannerConfiguration.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    var attrId = bnet.protocol.attribute.Attribute.CreateBuilder()
                        .SetName("CustomMessageId")
                        .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(5).Build())
                        .Build();
                    builder.AddAttribute(attrId);
                    break;
                case 7: // Client doesn't care what you send here
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    break;
                case 8: //D3.GameMessage.SetGameAccountSettings ->
                    var setAccountSettings = SetGameAccountSettings(D3.GameMessage.SetGameAccountSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(setAccountSettings).Build());
                    break;
                case 9: //D3.GameMessage.GetToonSettings? -> D3.Client.ToonSettings
                    var getToonSettings = GetToonSettings(D3.GameMessage.GetToonSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getToonSettings).Build());
                    break;
                case 10: //D3.GameMessage.SetToonSettings?
                    var setToonSettings = SetToonSettings(D3.GameMessage.SetToonSettings.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(setToonSettings).Build());
                    break;
                case 12: //D3.GameMessage.GetHeroItems
                    var heroItems = GetHeroItems(D3.GameMessage.GetHeroItems.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(heroItems).Build());
                    break;
                case 13: //D3.GameMessage.GetAccountItems
                    var accountItems = GetAccountItems(D3.GameMessage.GetAccountItems.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(accountItems).Build());
                    var attr2 = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("stashSlots");
                    attr2.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetUintValue(14).Build());
                    builder.AddAttribute(attr2);
                    break;
                case 14: //D3.GameMessage.GetAccountProfile -> D3.Profile.AccountProfile
                    var getAccountProfile = GetAccountProfile(D3.GameMessage.GetAccountProfile.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getAccountProfile).Build());
                    break;
                case 15: //D3.GameMessage.GetHeroProfiles -> D3.Profile.HeroProfileList
                    var getHeroProfiles = GetHeroProfiles(D3.GameMessage.GetHeroProfiles.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(getHeroProfiles).Build());
                    break;
                case 16: //? - Client expecting D3.Client.Preferences
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(D3.Client.Preferences.CreateBuilder().SetVersion(106).Build().ToByteString()).Build());
                    break;
                case 19: // unknown? - beta client was using this for D3.GameMessage.GetHeroIds -> D3.Hero.HeroList but retail doesn't seem to so. /raist                    
                    /* beta client code;
                     * var HeroList = GetHeroList(D3.GameMessage.GetHeroIds.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                     *  attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(HeroList).Build()); 
                     */
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    break;
                case 20: //D3.GameMessage.UndeleteHero -> D3.Hero.Digest
                    var UndeletedHero = UndeleteHero(D3.GameMessage.UndeleteHero.ParseFrom(request.GetAttribute(2).Value.MessageValue));
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(UndeletedHero).Build());
                    break;
                case 21: //D3.GameMessage.? (contains GameAccount EntityId) -> empty CustomMessage ByteString and CustomMessage2 ByteString
                    attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    var CustomMessage2 = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("CustomMessage2");
                    CustomMessage2.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build());
                    break;
                case 23: //D3.GameMessage.GetDeletedHero -> D3.Hero.Digest or header status: 395003
                    var DeletedHero = GetDeletedHero();
                    if (DeletedHero != ByteString.Empty)
                        attr.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(DeletedHero).Build());
                    else
//.........这里部分代码省略.........
开发者ID:weltmeyer,项目名称:mooege,代码行数:101,代码来源:GameUtilitiesService.cs


注:本文中的bnet.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。