Пример #1
0
		private async void RequestLock()
		{
			try
			{
				Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(this.address);
				string serverAddress = Game.Scene.GetComponent<StartConfigComponent>().StartConfig.ServerIP;
				G2G_LockRequest request = new G2G_LockRequest { Id = this.Owner.Id, Address = serverAddress };
				await session.Call<G2G_LockRequest, G2G_LockResponse>(request);

				this.status = LockStatus.Locked;

				foreach (TaskCompletionSource<bool> taskCompletionSource in this.queue)
				{
					taskCompletionSource.SetResult(true);
				}
				this.queue.Clear();
			}
			catch (Exception e)
			{
				Log.Error($"获取锁失败: {this.address} {this.Owner.Id} {e}");
			}
		}
Пример #2
0
        private async void RequestLock()
        {
            try
            {
                Session         session       = Game.Scene.GetComponent <NetInnerComponent>().Get(this.address);
                string          serverAddress = Game.Scene.GetComponent <StartConfigComponent>().StartConfig.ServerIP;
                G2G_LockRequest request       = new G2G_LockRequest {
                    Id = this.Entity.Id, Address = serverAddress
                };
                await session.Call <G2G_LockResponse>(request);

                this.status = LockStatus.Locked;

                foreach (TaskCompletionSource <bool> taskCompletionSource in this.queue)
                {
                    taskCompletionSource.SetResult(true);
                }
                this.queue.Clear();
            }
            catch (Exception e)
            {
                Log.Error($"获取锁失败: {this.address} {this.Entity.Id} {e}");
            }
        }