Ejemplo n.º 1
0
 public virtual void rpc_HandleSystem(SystemStaticServicesStartedNotify shutdown)
 {
     area_manager.CallAsync <RegistAreaResponse>(new RegistAreaRequest()
     {
         areaName = SelfAddress.ServiceName,
         areaNode = SelfAddress.ServiceNode,
     });
 }
Ejemplo n.º 2
0
        public async Task <PlayGameResponse> rpc_PlayGameAsync(PlayGameRequest req)
        {
            // <--- 此处如果不加锁,假如同时两个PlayGameRequest过来,则可能会导致coinCount为负数
            using (await this.coinLocker.LockAsync())
            {
                //判断硬币数量够不够
                if (coinCount > req.count)
                {
                    //异步调用
                    var rsp = await machine.CallAsync <PlayGameResponse>(req);

                    //消耗硬币
                    coinCount -= rsp.usedCoin;
                    //返回结果
                    return(rsp);
                }
                //返回失败结果
                return(new PlayGameResponse()
                {
                    s2c_code = Response.CODE_ERROR
                });
            }
        }