コード例 #1
0
        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());
        }
コード例 #2
0
        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
                        this.Status = 395003;
                    //LastCallHeader = LastCallHeader.ToBuilder().SetStatus(395003).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());
        }