Beispiel #1
0
        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action <bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
            case EntityIdHelper.HighIdType.AccountId:
                var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                if (account != null)
                {
                    Logger.Trace("Subscribe() {0} {1}", this.Client, account);
                    account.AddSubscriber(this.Client, request.ObjectId);
                }
                break;

            case EntityIdHelper.HighIdType.GameAccountId:
                var gameaccount = GameAccountManager.GetAccountByPersistentID(request.EntityId.Low);
                if (gameaccount != null)
                {
                    Logger.Trace("Subscribe() {0} {1}", this.Client, gameaccount);
                    gameaccount.AddSubscriber(this.Client, request.ObjectId);
                }
                break;

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

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

            done(builder.Build());
        }
Beispiel #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());
        }