Example #1
0
        /// <summary>
        /// 请求加锁
        /// </summary>
        /// <param name="self"></param>
        private static async void RequestLock(this LockComponent self)
        {
            try
            {
                ///这个需要加锁的角色的IP
                Session         session       = Game.Scene.GetComponent <NetInnerComponent>().Get(self.address);
                string          serverAddress = StartConfigComponent.Instance.StartConfig.ServerIP;
                G2G_LockRequest request       = new G2G_LockRequest {
                    Id = self.Entity.Id, Address = serverAddress
                };
                await session.Call(request);

                self.status = LockStatus.Locked;
                //所有的请求都确定  加锁成功
                foreach (TaskCompletionSource <bool> taskCompletionSource in self.queue)
                {
                    taskCompletionSource.SetResult(true);
                }
                self.queue.Clear();
            }
            catch (Exception e)
            {
                Log.Error($"获取锁失败: {self.address} {self.Entity.Id} {e}");
            }
        }
Example #2
0
 public virtual async ETTask G2G_LockRequestHandler(Scene scene, G2G_LockRequest request, G2G_LockResponse response, Action reply)
 {
 }