コード例 #1
0
 public HackShieldClient(HackShieldService service, IEntity entity, AntiCpXSvr.SafeClientHandle clientHandle)
 {
     this.Service        = service;
     this.Entity         = entity;
     this.Entity.Closed += delegate(object sender, EventArgs e)
     {
         if (!this.Handle.IsClosed)
         {
             this.Handle.Dispose();
         }
     };
     this.Handle = clientHandle;
 }
コード例 #2
0
        protected override IEntity MakeEntity(long id, string category)
        {
            AntiCpXSvr.SafeClientHandle safeClientHandle = new AntiCpXSvr.SafeClientHandle(this.serverHandle);
            if (safeClientHandle.IsInvalid)
            {
                Log <HackShieldService> .Logger.WarnFormat("Error while making Hackshield handler : {0}", id);

                return(null);
            }
            IEntity entity = base.MakeEntity(id, category);

            entity.Tag    = new HackShieldClient(this, entity, safeClientHandle);
            entity.Using += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (entity.Tag == null)
                {
                    return;
                }
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService")
                {
                    HackShieldClient hackShieldClient = entity.Tag as HackShieldClient;
                    if (hackShieldClient.FrontendConn != null)
                    {
                        hackShieldClient.FrontendConn.Close();
                    }
                    hackShieldClient.FrontendConn         = this.Connect(entity, new Location(value.RemoteID, value.RemoteCategory));
                    hackShieldClient.FrontendConn.Closed += delegate(object _, EventArgs <IEntityProxy> __)
                    {
                        entity.Close();
                    };
                    hackShieldClient.FrontendConn.OperationQueueOversized += delegate(object _, EventArgs <IEntityProxy> __)
                    {
                        entity.Close(true);
                    };
                }
            };
            entity.Closed += delegate(object sender, EventArgs e)
            {
                try
                {
                    EntityDataContext entityDataContext = new EntityDataContext();
                    entityDataContext.AcquireService(new long?((sender as IEntity).ID), base.Category, new int?(-1), new int?(base.ID));
                }
                catch (Exception ex)
                {
                    Log <HackShieldService> .Logger.ErrorFormat("Entity_Closed [EntityID : {0}] [ServiceID : {1}] [Category : {2}] - {3} ", new object[]
                    {
                        (sender as IEntity).ID,
                        base.ID,
                        base.Category,
                        ex
                    });
                }
            };
            entity.Used += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                if (entity.UseCount == 0)
                {
                    entity.Close();
                }
            };
            if (!FeatureMatrix.IsEnable("HackShieldConnCheckOff"))
            {
                Scheduler.Schedule(base.Thread, Job.Create(new Action((entity.Tag as HackShieldClient).MakeRequest)), this.NextMilliseconds());
            }
            if (FeatureMatrix.IsEnable("TcProtect"))
            {
                Scheduler.Schedule(base.Thread, Job.Create(new Action((entity.Tag as HackShieldClient).MakeTcProtectRequest)), 0);
            }
            return(entity);
        }