public void Revoke(MooNetClient client, bnet.protocol.channel_invitation.RevokeInvitationRequest request)
        {
            if (!this._onGoingInvitations.ContainsKey(request.InvitationId))
            {
                return;
            }
            var invitation = this._onGoingInvitations[request.InvitationId];

            //notify inviter about revoke
            var updateChannelNotification =
                bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /dustin
                .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder()
                                .AddInvitation(invitation)
                                .SetReason((uint)InvitationRemoveReason.Revoked));

            this._onGoingInvitations.Remove(request.InvitationId);

            client.MakeTargetedRPC(client.CurrentChannel, () =>
                                   bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, updateChannelNotification.Build(), callback => { }));

            //notify invitee about revoke
            var invitationRemoved =
                bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder()
                .SetInvitation(invitation)
                .SetReason((uint)InvitationRemoveReason.Revoked);

            var invitee = ToonManager.GetToonByLowID(invitation.InviteeIdentity.ToonId.Low);

            invitee.Owner.LoggedInClient.MakeTargetedRPC(this, () =>
                                                         bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(invitee.Owner.LoggedInClient).NotifyReceivedInvitationRemoved(null, invitationRemoved.Build(), callback => { }));
        }
Exemple #2
0
        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action <bnet.protocol.NoData> done)
        {
            Logger.Trace("Subscribe() {0}: {1}", request.EntityId.GetHighIdType(), request.EntityId.Low);

            switch (request.EntityId.GetHighIdType())
            {
            case EntityIdHelper.HighIdType.AccountId:
                this.Client.Account.AddSubscriber((BNetClient)this.Client, request.ObjectId);
                break;

            case EntityIdHelper.HighIdType.ToonId:
                var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
                // The client will send us a Subscribe with ToonId of 0 the first time it
                // tries to create a toon with a name that already exists. Let's handle that here.
                if (toon != null)
                {
                    toon.AddSubscriber((BNetClient)this.Client, request.ObjectId);
                }
                break;

            default:
                Logger.Warn("Recieved an unhandled Presence.Subscribe request with type {0}", request.EntityId.GetHighIdType());
                break;
            }

            var builder = NoData.CreateBuilder();

            done(builder.Build());
        }
Exemple #3
0
        public override void Update(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UpdateRequest request, System.Action <bnet.protocol.NoData> done)
        {
            Logger.Trace("Update() {0}: {1}", request.EntityId.GetHighIdType(), request.EntityId.Low);
            //Logger.Warn("request:\n{0}", request.ToString());
            // This "UpdateRequest" is not, as it may seem, a request to update the client on the state of an object,
            // but instead the *client* requesting to change fields on an object that it has subscribed to.
            // Check docs/rpc/presence.txt in branch wip-docs (or master)

            switch (request.EntityId.GetHighIdType())
            {
            case EntityIdHelper.HighIdType.AccountId:
                var account = AccountManager.GetAccountByEntityID(request.EntityId);
                break;

            case EntityIdHelper.HighIdType.ToonId:
                var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
                break;

            default:
                Logger.Warn("Recieved an unhandled Presence.Update request with type {0}", request.EntityId.GetHighIdType());
                break;
            }

            var builder = NoData.CreateBuilder();

            done(builder.Build());
        }
Exemple #4
0
 /// <summary>
 /// アンマネージ リソースの解放およびリセットに関連付けられているアプリケーション定義のタスクを実行します。
 /// </summary>
 public virtual void Dispose()
 {
     Effect.Dispose();
     BufferManager.Dispose();
     ToonManager.Dispose();
     SubsetManager.Dispose();
 }
        private ByteString GetHeroProfiles(D3.GameMessage.GetHeroProfiles profiles)
        {
            Logger.Trace("GetHeroProfiles()");

            var profileList = D3.Profile.HeroProfileList.CreateBuilder();

            if (profiles.HeroIdsCount > 0)
            {
                foreach (var hero in profiles.HeroIdsList)
                {
                    var toon = ToonManager.GetToonByLowID(hero.IdLow);
                    profileList.AddHeros(toon.Profile);
                }
            }
            else
            {
                var heroList = GameAccountManager.GetAccountByPersistentID(profiles.AccountId.IdLow).Toons;
                foreach (var hero in heroList)
                {
                    profileList.AddHeros(hero.Profile);
                }
            }

            return(profileList.Build().ToByteString());
        }
Exemple #6
0
        public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action <bnet.protocol.NoData> done)
        {
            Logger.Trace("Unsubscribe()");
            Logger.Debug("request:\n{0}", request.ToString());

            switch (request.EntityId.GetHighIdType())
            {
            case EntityIdHelper.HighIdType.AccountId:
                var account = AccountManager.GetAccountByEntityID(request.EntityId);
                // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
                if (account != null)
                {
                    account.RemoveSubscriber((BNetClient)this.Client);
                }
                break;

            case EntityIdHelper.HighIdType.ToonId:
                var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
                if (toon != null)
                {
                    toon.RemoveSubscriber((BNetClient)this.Client);
                }
                break;

            default:
                Logger.Warn("Recieved an unhandled Presence.Unsubscribe request with type {0}", request.EntityId.GetHighIdType());
                break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();

            done(builder.Build());
        }
Exemple #7
0
        /// <summary>
        /// Loads the specified render context.
        /// </summary>
        /// <param name="renderContext">The render context.</param>
        public void Load(RenderContext renderContext)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            RenderContext = renderContext;
            Device device = RenderContext.DeviceManager.Device;

            if (!IsInitialized)
            {
//モデルの読み込みなどはリセットしない
                //シェーダーの読み込み
                ToonManager.Initialize(RenderContext, SubresourceLoader);
                SubsetManager.Initialze(RenderContext, Effect, SubresourceLoader, ToonManager);
                Effect = InitializeEffect();
                SubsetManager.ResetEffect(Effect);

                //定数バッファ
                //PhongConstantBuffer.Initialize(device, Effect.EffectFile,
                //    PhongShadingConstantBufferInputLayout.SizeInBytes, new PhongShadingConstantBufferInputLayout());
                ZPlotPass = Effect.EffectFile.GetTechniqueByIndex(1).GetPassByIndex(0);
                InitializeBuffers(device);
                Skinning      = InitializeSkinning();
                Morphmanager  = new PMXMorphManager(this);
                IsInitialized = true;
            }
            MotionManager = InitializeMotionManager();
            InitializeOther(device);
            sw.Stop();
            Trace.WriteLine(sw.ElapsedMilliseconds + "ms");
        }
        public override void SendNotification(IRpcController controller, Notification request, Action <NoData> done)
        {
            Logger.Trace("SendNotification()");
            Logger.Debug("notification:\n{0}", request.ToString());

            switch (request.GetNotificationType())
            {
            case NotificationTypeHelper.NotificationType.Whisper:
                // Hackztime deluxe
                // TODO: The notification on the recipient's side will end up with no name, and
                // the recipient doesn't even send a subscribe request or something like that when trying to respond
                // Need more data to figure this out..
                var account = ToonManager.GetAccountByToonLowID(request.TargetId.Low);
                var method  = bnet.protocol.notification.NotificationListener.Descriptor.FindMethodByName("OnNotificationReceived");
                account.LoggedInBNetClient.CallMethod(method, request, 0);
                break;

            default:
                Logger.Warn("Unhandled notification type: {0}", request.Type);
                break;
            }

            var builder = NoData.CreateBuilder();

            done(builder.Build());
        }
Exemple #9
0
        public override void SuggestInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.SuggestInvitationRequest request, Action <bnet.protocol.NoData> done)
        {
            var suggester = ToonManager.GetToonByLowID(request.TargetId.Low);   //wants invite
            var suggestee = ToonManager.GetToonByLowID(request.ApprovalId.Low); //approves invite

            if (suggestee == null)
            {
                return;
            }

            Logger.Debug("{0} suggested {1} to invite him.", suggester, suggestee);
            var respone = bnet.protocol.NoData.CreateBuilder();

            done(respone.Build());

            // Even though it makes no sense, the suggester is used for all fields in the caps and is what works with the client. /dustinconrad
            var suggestion = bnet.protocol.invitation.Suggestion.CreateBuilder()
                             .SetChannelId(request.ChannelId)
                             .SetSuggesterId(suggester.BnetEntityID)
                             .SetSuggesterName(suggester.Name)
                             .SetSuggesteeId(suggester.BnetEntityID)
                             .SetSuggesteeName(suggester.Name)
                             .Build();

            var notification = bnet.protocol.channel_invitation.SuggestionAddedNotification.CreateBuilder().SetSuggestion(suggestion);

            suggestee.Owner.LoggedInClient.MakeTargetedRPC(this._invitationManager, () =>
                                                           bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(suggestee.Owner.LoggedInClient).NotifyReceivedSuggestionAdded(null, notification.Build(), callback => { }));
        }
Exemple #10
0
        public override void SendInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.invitation.SendInvitationRequest request, System.Action <bnet.protocol.invitation.SendInvitationResponse> done)
        {
            var invitee = ToonManager.GetToonByLowID(request.TargetId.Low);

            Logger.Warn(String.Format("{0} invited {1} to his channel.", Client.CurrentToon.Name, invitee.Name));

            // somehow protobuf lib doesnt handle this extension, so we're using a workaround to get that channelinfo.
            var extensionBytes        = request.UnknownFields.FieldDictionary[105].LengthDelimitedList[0].ToByteArray();
            var channelInvitationInfo = bnet.protocol.channel_invitation.SendInvitationRequest.ParseFrom(extensionBytes);

            var channelInvitation = bnet.protocol.channel_invitation.Invitation.CreateBuilder()
                                    .SetChannelDescription(bnet.protocol.channel.ChannelDescription.CreateBuilder().SetChannelId(channelInvitationInfo.ChannelId).Build())
                                    .SetReserved(channelInvitationInfo.Reserved)
                                    .SetServiceType(channelInvitationInfo.ServiceType)
                                    .SetRejoin(false).Build();

            var invitation = bnet.protocol.invitation.Invitation.CreateBuilder(); // also need to add creation_time, expiration_time.

            invitation.SetId(1)                                                   // TODO: fix the id
            .SetInviterIdentity(bnet.protocol.Identity.CreateBuilder().SetToonId(Client.CurrentToon.BnetEntityID).Build())
            .SetInviterName(Client.CurrentToon.Name)
            .SetInviteeIdentity(bnet.protocol.Identity.CreateBuilder().SetToonId(request.TargetId).Build())
            .SetInviteeName(invitee.Name)
            .SetInvitationMessage(request.InvitationMessage)
            .SetCreationTime(DateTime.Now.ToUnixTime())
            .SetExpirationTime(DateTime.Now.ToUnixTime() + request.ExpirationTime)
            .SetExtension(bnet.protocol.channel_invitation.Invitation.ChannelInvitation, channelInvitation);

            var builder = bnet.protocol.invitation.SendInvitationResponse.CreateBuilder()
                          .SetInvitation(invitation);

            done(builder.Build());
        }
        public void HandleDecline(MooNetClient client, bnet.protocol.invitation.GenericRequest request)
        {
            if (!this._onGoingInvitations.ContainsKey(request.InvitationId))
            {
                return;
            }
            var invitation = this._onGoingInvitations[request.InvitationId];

            var inviter = ToonManager.GetToonByLowID(invitation.InviterIdentity.ToonId.Low);

            if (inviter == null || inviter.Owner.LoggedInClient == null)
            {
                return;
            }

            var notification =
                bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /raist.
                .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddInvitation(invitation)
                                .SetReason((uint)InvitationRemoveReason.Declined));

            this._onGoingInvitations.Remove(invitation.Id);

            // notify invoker about the decline.
            inviter.Owner.LoggedInClient.MakeTargetedRPC(inviter.Owner.LoggedInClient.CurrentChannel, () =>
                                                         bnet.protocol.channel.ChannelSubscriber.CreateStub(inviter.Owner.LoggedInClient).NotifyUpdateChannelState(null, notification.Build(), callback => { }));
        }
Exemple #12
0
        public static void DeleteGameAccount(GameAccount gameAccount)
        {
            if (gameAccount == null)
            {
                return;
            }
            if (LoadedGameAccounts.Contains(gameAccount))
            {
                LoadedGameAccounts.Remove(gameAccount);
            }

            //Delete all toons for game account
            foreach (var toon in ToonManager.GetToonsForGameAccount(gameAccount))
            {
                ToonManager.DeleteToon(toon);
            }


            var inventoryToDelete = DBSessions.AccountSession.Query <DBInventory>().Where(inv => inv.DBGameAccount.Id == gameAccount.DBGameAccount.Id);

            foreach (var inv in inventoryToDelete)
            {
                DBSessions.AccountSession.Delete(inv);
            }



            gameAccount.DBGameAccount.DBAccount.DBGameAccounts.Remove(gameAccount.DBGameAccount);

            DBSessions.AccountSession.Update(gameAccount.DBGameAccount.DBAccount);
            DBSessions.AccountSession.Delete(gameAccount.DBGameAccount);
            DBSessions.AccountSession.Flush();
        }
Exemple #13
0
        public override void FindGame(IRpcController controller, bnet.protocol.game_master.FindGameRequest request, Action <bnet.protocol.game_master.FindGameResponse> done)
        {
            Logger.Trace("FindGame() {0}", this.Client);

            // find the game.
            var gameFound = GameFactoryManager.FindGame(this.Client, request, ++GameFactoryManager.RequestIdCounter);

            //TODO: All these ChannelState updates can be moved to functions someplace else after packet flow is discovered and working -Egris
            //Send current JoinPermission to client before locking it
            var channelStatePermission = bnet.protocol.channel.ChannelState.CreateBuilder()
                                         .AddAttribute(bnet.protocol.attribute.Attribute.CreateBuilder()
                                                       .SetName("D3.Party.JoinPermissionPreviousToLock")
                                                       .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1).Build())
                                                       .Build()).Build();

            var notificationPermission = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                                         .SetAgentId(this.Client.CurrentToon.BnetEntityID)
                                         .SetStateChange(channelStatePermission)
                                         .Build();

            this.Client.MakeTargetedRPC(Client.CurrentChannel, () =>
                                        bnet.protocol.channel.ChannelSubscriber.CreateStub(this.Client).NotifyUpdateChannelState(null, notificationPermission, callback => { }));

            var builder = bnet.protocol.game_master.FindGameResponse.CreateBuilder().SetRequestId(gameFound.RequestId);

            done(builder.Build());

            var clients = new List <MooNetClient>();

            foreach (var player in request.PlayerList)
            {
                var toon = ToonManager.GetToonByLowID(player.ToonId.Low);
                if (toon.Owner.LoggedInClient == null)
                {
                    continue;
                }
                clients.Add(toon.Owner.LoggedInClient);
            }

            // send game found notification.
            var notificationBuilder = bnet.protocol.game_master.GameFoundNotification.CreateBuilder()
                                      .SetRequestId(gameFound.RequestId)
                                      .SetGameHandle(gameFound.GameHandle);

            this.Client.MakeRPCWithListenerId(request.ObjectId, () =>
                                              bnet.protocol.game_master.GameFactorySubscriber.CreateStub(this.Client).NotifyGameFound(null, notificationBuilder.Build(), callback => { }));

            if (gameFound.Started)
            {
                Logger.Warn("Client {0} joining game with FactoryID:{1}", this.Client.CurrentToon.Name, gameFound.FactoryID);
                gameFound.JoinGame(clients, request.ObjectId);
            }
            else
            {
                Logger.Warn("Client {0} creating new game", this.Client.CurrentToon.Name);
                gameFound.StartGame(clients, request.ObjectId);
            }
        }
Exemple #14
0
        private ByteString DeleteHero(D3.OnlineService.EntityId hero)
        {
            var deleteToon = ToonManager.GetToonByLowID(hero.IdLow);

            ToonManager.DeleteToon(deleteToon);

            Logger.Trace("DeleteHero() {0}", deleteToon);
            return(ByteString.Empty);
        }
        private ByteString SetToonSettings(D3.GameMessage.SetToonSettings settings)
        {
            Logger.Trace("SetToonSettings()");

            var toon = ToonManager.GetToonByLowID(settings.HeroId.IdLow);

            toon.Settings = settings.Settings;
            return(ByteString.Empty);
        }
Exemple #16
0
        public override void SelectToon(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.toon.external.SelectToonRequest request, Action <bnet.protocol.toon.external.SelectToonResponse> done)
        {
            var builder = bnet.protocol.toon.external.SelectToonResponse.CreateBuilder();
            var toon    = ToonManager.GetToonByLowID(request.Toon.Low);

            this.Client.CurrentToon = toon;
            done(builder.Build());

            Logger.Trace("SelectToon() {0}", toon);
        }
Exemple #17
0
        private ByteString SelectHero(D3.OnlineService.EntityId hero)
        {
            this.Client.Account.CurrentGameAccount.CurrentToon = ToonManager.GetToonByLowID(hero.IdLow);

            Logger.Trace("SelectToon() {0}", this.Client.Account.CurrentGameAccount.CurrentToon);
            this.Client.Account.LastSelectedHeroField.Value = this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID;
            this.Client.Account.CurrentGameAccount.NotifyUpdate();
            this.Client.Account.SaveToDB();
            return(this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID.ToByteString());
        }
Exemple #18
0
        public override void SendInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.invitation.SendInvitationRequest request, Action <bnet.protocol.invitation.SendInvitationResponse> done)
        {
            var invitee = ToonManager.GetToonByLowID(request.TargetId.Low);

            if (this.Client.CurrentChannel.HasToon(invitee))
            {
                return;                                              // don't allow a second invitation if invitee is already a member of client's current channel.
            }
            Logger.Debug("{0} invited {1} to his channel.", Client.CurrentToon, invitee);

            // somehow protobuf lib doesnt handle this extension, so we're using a workaround to get that channelinfo.
            var extensionBytes        = request.UnknownFields.FieldDictionary[105].LengthDelimitedList[0].ToByteArray();
            var channelInvitationInfo = bnet.protocol.channel_invitation.SendInvitationRequest.ParseFrom(extensionBytes);

            var channelInvitation = bnet.protocol.channel_invitation.Invitation.CreateBuilder()
                                    .SetChannelDescription(bnet.protocol.channel.ChannelDescription.CreateBuilder().SetChannelId(channelInvitationInfo.ChannelId).Build())
                                    .SetReserved(channelInvitationInfo.Reserved)
                                    .SetServiceType(channelInvitationInfo.ServiceType)
                                    .SetRejoin(false).Build();

            var invitation = bnet.protocol.invitation.Invitation.CreateBuilder();

            invitation.SetId(ChannelInvitationManager.InvitationIdCounter++)
            .SetInviterIdentity(bnet.protocol.Identity.CreateBuilder().SetToonId(Client.CurrentToon.BnetEntityID).Build())
            .SetInviterName(Client.CurrentToon.Name)
            .SetInviteeIdentity(bnet.protocol.Identity.CreateBuilder().SetToonId(request.TargetId).Build())
            .SetInviteeName(invitee.Name)
            .SetInvitationMessage(request.InvitationMessage)
            .SetCreationTime(DateTime.Now.ToExtendedEpoch())
            .SetExpirationTime(DateTime.Now.ToUnixTime() + request.ExpirationTime)
            .SetExtension(bnet.protocol.channel_invitation.Invitation.ChannelInvitation, channelInvitation);

            // oh blizz, cmon. your buggy client even doesn't care this message at all but waits the UpdateChannelStateNotification with embedded invitation proto to show "invitation sent message".
            // ADVICE TO POTENTIAL BLIZZ-WORKER READING THIS;
            // change rpc SendInvitation(.bnet.protocol.invitation.SendInvitationRequest) returns (.bnet.protocol.invitation.SendInvitationResponse); to rpc SendInvitation(.bnet.protocol.invitation.SendInvitationRequest) returns (.bnet.protocol.NoData);

            var builder = bnet.protocol.invitation.SendInvitationResponse.CreateBuilder()
                          .SetInvitation(invitation.Clone()); // clone it because we need that invitation as un-builded below.

            done(builder.Build());

            // send bnet.protocol.channel.UpdateChannelStateNotification to inviter - update him on invitation is sent.

            var notification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                               .SetAgentId(Client.CurrentToon.BnetEntityID)
                               .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddInvitation(invitation.Clone()));

            this.Client.MakeTargetedRPC(this.Client.CurrentChannel, () =>
                                        bnet.protocol.channel.ChannelSubscriber.CreateStub(Client).NotifyUpdateChannelState(controller, notification.Build(), callback => { }));

            // notify the invitee on invitation.
            this._invitationManager.HandleInvitation(this.Client, invitation.Build());
        }
Exemple #19
0
        private ByteString CreateHero(D3.OnlineService.HeroCreateParams createPrams)
        {
            int hashCode = ToonManager.GetUnusedHashCodeForToonName(createPrams.Name);
            var newToon  = new Toon(createPrams.Name, hashCode, createPrams.GbidClass, createPrams.IsFemale ? ToonFlags.Female : ToonFlags.Male, 1, Client.Account.CurrentGameAccount);

            if (ToonManager.SaveToon(newToon))
            {
                Logger.Trace("CreateHero() {0}", newToon);
                return(newToon.D3EntityID.ToByteString());
            }
            return(ByteString.Empty);
        }
Exemple #20
0
        public static void RemovePlayerFromGame(Net.GS.GameClient gameClient)
        {
            if (gameClient == null || gameClient.Game == null)
            {
                return;
            }

            var gameId = gameClient.Game.GameId;

            if (!Games.ContainsKey(gameId))
            {
                return;
            }

            var game = Games[gameId];

            if (!game.Players.ContainsKey(gameClient))
            {
                return;
            }

            Player p = null;

            if (!game.Players.TryRemove(gameClient, out p))
            {
                Logger.Error("Can't remove player ({0}) from game with id: {1}", gameClient.Player.Toon.Name, gameId);
            }

            if (p != null)
            {
                //TODO: Move this inside player OnLeave event
                var toon = p.Toon;
                toon.TimePlayed    += DateTimeExtensions.ToUnixTime(DateTime.UtcNow) - toon.LoginTime;
                toon.ExperienceNext = p.Attributes[GameAttribute.Experience_Next];

                // Remove Player From World
                if (p.InGameClient != null)
                {
                    p.World.Leave(p);
                }

                // Generate Update for Client
                gameClient.BnetClient.Account.CurrentGameAccount.NotifyUpdate();
                //save hero to db after player data was updated in toon
                ToonManager.SaveToDB(toon);
            }

            if (game.Players.Count == 0)
            {
                Games.Remove(gameId); // we should be also disposing it /raist.
            }
        }
Exemple #21
0
        public override void DeleteToon(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.toon.external.DeleteToonRequest request, Action <bnet.protocol.toon.external.DeleteToonResponse> done)
        {
            var id   = request.Toon.Low;
            var toon = ToonManager.GetToonByLowID(id);

            ToonManager.DeleteToon(toon);

            var builder = bnet.protocol.toon.external.DeleteToonResponse.CreateBuilder();

            done(builder.Build());

            Logger.Trace("DeleteToon() {0}", toon);
        }
Exemple #22
0
        private ByteString SelectHero(D3.OnlineService.EntityId hero)
        {
            this.Client.Account.CurrentGameAccount.CurrentToon = ToonManager.GetToonByLowID(hero.IdLow);

            Logger.Trace("SelectToon() {0}", this.Client.Account.CurrentGameAccount.CurrentToon);

            if (this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID != this.Client.Account.CurrentGameAccount.lastPlayedHeroId)
            {
                this.Client.Account.CurrentGameAccount.NotifyUpdate();
                this.Client.Account.CurrentGameAccount.lastPlayedHeroId = this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID;
            }
            return(this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID.ToByteString());
        }
Exemple #23
0
        public override void CreateToon(Google.ProtocolBuffers.IRpcController controller, CreateToonRequest request, Action <CreateToonResponse> done)
        {
            Logger.Trace("CreateToon()");
            var heroCreateParams = D3.OnlineService.HeroCreateParams.ParseFrom(request.AttributeList[0].Value.MessageValue);
            var builder          = CreateToonResponse.CreateBuilder();

            var toon = new Toon(request.Name, heroCreateParams.GbidClass, heroCreateParams.IsFemale ? ToonFlags.Female : ToonFlags.Male, 1, Client.Account);

            if (ToonManager.SaveToon(toon))
            {
                builder.SetToon(toon.BnetEntityID);
            }
            done(builder.Build());
        }
        private ByteString GetToonSettings(D3.GameMessage.GetToonSettings settings)
        {
            Logger.Trace("GetToonSettings");

            if (settings.HasHeroId)
            {
                var toon = ToonManager.GetToonByLowID(settings.HeroId.IdLow);
                return(toon.Settings.ToByteString());
            }
            else
            {
                return(this.Client.Account.CurrentGameAccount.CurrentToon.Settings.ToByteString());
            }
        }
        private ByteString UndeleteHero(D3.GameMessage.UndeleteHero heroId)
        {
            var toon = ToonManager.GetToonByLowID(heroId.UndeleteHeroId.IdLow);

            if (toon != null && toon.Deleted)
            {
                toon.Deleted = false;
                ToonManager.SaveToDB(toon);
                return(toon.Digest.ToByteString());
            }
            else
            {
                return(ByteString.Empty);
            }
        }
        private ByteString SelectHero(D3.OnlineService.EntityId hero)
        {
            var oldToon = this.Client.Account.CurrentGameAccount.CurrentToon;
            var newtoon = ToonManager.GetToonByLowID(hero.IdLow);


            Logger.Trace("SelectToon() {0}", this.Client.Account.CurrentGameAccount.CurrentToon);

            if (oldToon != newtoon)
            {
                this.Client.Account.CurrentGameAccount.CurrentToon = newtoon;
                this.Client.Account.CurrentGameAccount.NotifyUpdate();
                AccountManager.SaveToDB(this.Client.Account);
            }
            return(this.Client.Account.CurrentGameAccount.CurrentToon.D3EntityID.ToByteString());
        }
Exemple #27
0
        public override void Query(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.QueryRequest request, System.Action <bnet.protocol.presence.QueryResponse> done)
        {
            Logger.Trace("Query() {0}: {1}", request.EntityId.GetHighIdType(), request.EntityId.Low);

            var builder = bnet.protocol.presence.QueryResponse.CreateBuilder();
            var toon    = ToonManager.GetToonByLowID(request.EntityId.Low);

            foreach (var key in request.KeyList)
            {
                var field = toon.QueryField(key);
                if (field != null)
                {
                    builder.AddField(field);
                }
            }

            done(builder.Build());
        }
        private void DeleteHero(D3.OnlineService.EntityId hero)
        {
            //Permanantly delete previously deleted hero
            var deleteHero = ToonManager.GetDeletedToon(this.Client.Account.CurrentGameAccount);

            if (deleteHero != null)
            {
                Logger.Trace("Permanantly deleting hero: {0}", deleteHero);
                ToonManager.DeleteToon(deleteHero);
            }
            //Mark hero as deleted
            var markHero = ToonManager.GetToonByLowID(hero.IdLow);

            markHero.Deleted = true;
            ToonManager.SaveToDB(markHero);

            Logger.Trace("DeleteHero(): Marked {0} as deleted.", markHero);
        }
Exemple #29
0
        public static void DeleteGameAccount(GameAccount GameAccount)
        {
            if (!GameAccounts.ContainsKey(GameAccount.PersistentID))
            {
                Logger.Error("Attempting to delete game account that does not exist: {0}", GameAccount.PersistentID);
                return;
            }

            //Delete all toons for game account
            foreach (var toon in ToonManager.GetToonsForGameAccount(GameAccount).Values)
            {
                ToonManager.DeleteToon(toon);
            }

            if (GameAccount.DeleteFromDB())
            {
                GameAccounts.Remove(GameAccount.PersistentID);
            }
        }
        private ByteString GetHeroDigestList(D3.GameMessage.HeroDigestListRequest request)
        {
            Logger.Trace("GetHeroDigestList()");

            var ListResponse = D3.GameMessage.HeroDigestListResponse.CreateBuilder();

            foreach (var toon in request.ToonIdList)
            {
                var digest = ToonManager.GetToonByLowID(toon.IdLow).Digest;
                ListResponse.AddDigestList(
                    D3.GameMessage.HeroDigestResponse.CreateBuilder()
                    .SetToonId(toon)
                    .SetSuccess(true)
                    .SetHeroDigest(digest)
                    .Build()
                    );
            }
            return(ListResponse.Build().ToByteString());
        }