Exemple #1
0
        public async Task PlayNow(MoneyType moneyType, int roomId)
        {
            if (!_checker.CheckMoneyType(moneyType))
            {
                return;
            }

            if (!_checker.CheckRoom(roomId))
            {
                return;
            }

            try
            {
                long   accountId   = AccountSession.AccountID;
                string accountName = AccountSession.AccountName;
                if (accountId < 1)
                {
                    return;
                }

                var connections = ConnectionHandler.Instance.GetConnections(accountId);
                if (connections.Count > 1)
                {
                    var currentConnection = Context.ConnectionId;
                    foreach (var other in connections.Where(con => !con.Equals(currentConnection)))
                    {
                        if (currentConnection != other)
                        {
                            Clients.Client(other).message(GameMessage.OtherDevices, MessageFactory.GetMessage(GameMessage.OtherDevices));
                        }
                    }
                }
                var accountInfo = GameHandler.Instance.GetAccountInfo(accountId, accountName, roomId, moneyType, out var response);
                if (response > 0)
                {
                    if (moneyType == MoneyType.Gold)
                    {
                        await Groups.Remove(Context.ConnectionId, "Coin");

                        await Groups.Add(Context.ConnectionId, "Gold");
                    }
                    else
                    {
                        await Groups.Remove(Context.ConnectionId, "Gold");

                        await Groups.Add(Context.ConnectionId, "Coin");
                    }
                    Clients.Caller.JoinRoom(accountInfo);
                }
                // bổ sung đoạn chặn gọi quá nhiều thông tin info / khoảng thời gian

                // Xử lý lấy thông tin của người chơi
            }
            catch (Exception e)
            {
                NLogManager.PublishException(e);
            }
        }