Ejemplo n.º 1
0
        public Task WaitTillAsync(long tillTime)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            Timer timer = new Timer {
                Id = IdGenerater.GenerateId(), Time = tillTime, tcs = tcs
            };

            this.timers[timer.Id] = timer;
            this.timeId.Add(timer.Time, timer.Id);
            return(tcs.Task);
        }
Ejemplo n.º 2
0
        public Task WaitAsync(long time, CancellationToken cancellationToken)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            Timer timer = new Timer {
                Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs
            };

            this.timers[timer.Id] = timer;
            this.timeId.Add(timer.Time, timer.Id);
            cancellationToken.Register(() => { this.Remove(timer.Id); });
            return(tcs.Task);
        }
Ejemplo n.º 3
0
        public static Scene CreateScene(string name, Scene parent = null, long id = 0)
        {
            Scene scene = (Scene)Game.ObjectPool.Fetch(typeof(Scene));

            scene.Id   = id != 0 ? id : IdGenerater.GenerateId();
            scene.Name = name;
            if (parent != null)
            {
                scene.Parent = parent;
            }
            scene.Domain = scene;
            return(scene);
        }
Ejemplo n.º 4
0
        protected Entity()
        {
            this.InstanceId = IdGenerater.GenerateId();

#if !SERVER
            if (!this.GetType().IsDefined(typeof(HideInHierarchy), true))
            {
                this.ViewGO       = new GameObject();
                this.ViewGO.name  = this.GetType().Name;
                this.ViewGO.layer = LayerNames.GetLayerInt(LayerNames.HIDDEN);
                this.ViewGO.transform.SetParent(Global.transform, false);
            }
#endif
        }
Ejemplo n.º 5
0
        //            this.Id = STATIC_ID++;

        //			this.mNetwork = rNetwork;
        //			this.mChannel = rChannel;
        //            mChannel.Start();

        //            this.StartRecv();
        public Session(NetworkClient rNetwork, AChannel aChannel)
        {
            mNetwork     = rNetwork;
            this.channel = aChannel;
            this.requestCallback.Clear();
            this.Id = IdGenerater.GenerateId();
            long id = this.Id;

            channel.ErrorCallback += (c, e) =>
            {
                this.Network.Remove(id);
            };
            channel.ReadCallback += this.OnRead;

            this.channel.Start();
        }
Ejemplo n.º 6
0
        public Disposer Fetch(Type type)
        {
            EQueue <Disposer> queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue = new EQueue <Disposer>();
                this.dictionary.Add(type, queue);
            }
            Disposer obj;

            if (queue.Count > 0)
            {
                obj    = queue.Dequeue();
                obj.Id = IdGenerater.GenerateId();
                return(obj);
            }
            obj = (Disposer)Activator.CreateInstance(type);
            return(obj);
        }
Ejemplo n.º 7
0
 protected Component()
 {
     this.Id = IdGenerater.GenerateId();
 }
Ejemplo n.º 8
0
 protected AChannel(AService service, ChannelType channelType)
 {
     this.Id          = IdGenerater.GenerateId();
     this.ChannelType = channelType;
     this.service     = service;
 }
Ejemplo n.º 9
0
 protected Entity()
 {
     this.Id = IdGenerater.GenerateId();
 }
Ejemplo n.º 10
0
 protected Disposer() : base(IdGenerater.GenerateId())
 {
 }
Ejemplo n.º 11
0
 protected Disposer()
 {
     this.Id = IdGenerater.GenerateId();
     ObjectEvents.Instance.Add(this);
 }
Ejemplo n.º 12
0
 protected Disposer() : base(IdGenerater.GenerateId())
 {
     Game.Disposers.Add(this);
 }
Ejemplo n.º 13
0
 protected Object()
 {
     Id = IdGenerater.GenerateId();
     ObjectManager.Add(this);
 }
Ejemplo n.º 14
0
		protected Entity()
		{
			this.Id = IdGenerater.GenerateId();
			this.components = new HashSet<Component>();
			this.componentDict = new Dictionary<Type, Component>();
		}
Ejemplo n.º 15
0
 protected Disposer()
 {
     this.Id = IdGenerater.GenerateId();
 }
Ejemplo n.º 16
0
 protected Disposer() : base(IdGenerater.GenerateId())
 {
     ObjectEvents.Instance.Add(this);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 创建一个新Session
 /// </summary>
 public virtual Session Create(IPEndPoint ipEndPoint)
 {
     try
     {
         AChannel channel = this.Service.ConnectChannel(ipEndPoint);
         Session  session = ComponentFactory.CreateWithId <Session, NetworkComponent, AChannel>(IdGenerater.GenerateId(), this, channel);
         session.Parent         = this;
         channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
         this.sessions.Add(session.Id, session);
         return(session);
     }
     catch (Exception e)
     {
         Log.Error(e.ToString());
         return(null);
     }
 }
Ejemplo n.º 18
0
 protected Object()
 {
     Id = IdGenerater.GenerateId();
 }
Ejemplo n.º 19
0
        public virtual async Task <Session> Accept()
        {
            AChannel channel = await this.Service.AcceptChannel();

            Session session = ComponentFactory.CreateWithId <Session, NetworkComponent, AChannel>(IdGenerater.GenerateId(), this, channel);

            session.Parent         = this;
            channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
            this.sessions.Add(session.Id, session);
            return(session);
        }