Esempio n. 1
0
        protected override IEntity MakeEntity(long id, string category)
        {
            IEntity entity = base.MakeEntity(id, category);

            entity.Tag    = new CafeAuth(this, entity);
            entity.Using += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (entity.Tag == null)
                {
                    return;
                }
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService")
                {
                    CafeAuth cafeAuth = entity.Tag as CafeAuth;
                    if (cafeAuth.FrontendConn != null)
                    {
                        cafeAuth.FrontendConn.Close();
                    }
                    cafeAuth.FrontendConn = this.Connect(entity, new Location(value.RemoteID, value.RemoteCategory));
                }
            };
            entity.Used += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService" || entity.UseCount == 0)
                {
                    entity.Close();
                    Scheduler.Schedule(this.Thread, Job.Create(delegate
                    {
                        if (!entity.IsClosed)
                        {
                            entity.Close(true);
                        }
                    }), new TimeSpan(0, 0, 30));
                }
            };
            return(entity);
        }
Esempio n. 2
0
 private void Kick_User(CafeAuth target)
 {
     target.FrontendConn.RequestOperation(new DisconnectClient());
 }