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); }
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); }
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); }
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 }
// 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(); }
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); }
protected Component() { this.Id = IdGenerater.GenerateId(); }
protected AChannel(AService service, ChannelType channelType) { this.Id = IdGenerater.GenerateId(); this.ChannelType = channelType; this.service = service; }
protected Entity() { this.Id = IdGenerater.GenerateId(); }
protected Disposer() : base(IdGenerater.GenerateId()) { }
protected Disposer() { this.Id = IdGenerater.GenerateId(); ObjectEvents.Instance.Add(this); }
protected Disposer() : base(IdGenerater.GenerateId()) { Game.Disposers.Add(this); }
protected Object() { Id = IdGenerater.GenerateId(); ObjectManager.Add(this); }
protected Entity() { this.Id = IdGenerater.GenerateId(); this.components = new HashSet<Component>(); this.componentDict = new Dictionary<Type, Component>(); }
protected Disposer() { this.Id = IdGenerater.GenerateId(); }
protected Disposer() : base(IdGenerater.GenerateId()) { ObjectEvents.Instance.Add(this); }
/// <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); } }
protected Object() { Id = IdGenerater.GenerateId(); }
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); }