コード例 #1
0
        public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action <bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
            case EntityIdHelper.HighIdType.AccountId:
                var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
                if (account != null)
                {
                    account.RemoveSubscriber(this.Client);
                    Logger.Trace("Unsubscribe() {0} {1}", this.Client, account);
                }
                break;

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

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

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

            done(builder.Build());
        }
コード例 #2
0
ファイル: PresenceService.cs プロジェクト: rdavydov/d3sharp
        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());
        }