Exemplo n.º 1
0
        internal async Task OrderToSubsidize(OrderToSubsidize ots)
        {
            List <string> notifyMsg = new List <string>();

            if (BitCoin.Sign.checkSign(ots.signature, ots.Key, ots.address))
            {
                lock (this.PlayerLock)
                    if (this._Players.ContainsKey(ots.Key))
                    {
                        if (!this._Players[ots.Key].Bust)
                        {
                            long subsidizeGet, subsidizeLeft;
                            DalOfAddress.MoneyGet.GetSubsidizeAndLeft(ots.address, ots.value, out subsidizeGet, out subsidizeLeft);

                            var player = this._Players[ots.Key];
                            player.MoneySet(player.Money + subsidizeGet, ref notifyMsg);
                            //  player.setSupportToPlayMoney(player.SupportToPlayMoney + subsidizeGet, ref notifyMsg);

                            SendLeftMoney(player, subsidizeLeft, ots.address, ref notifyMsg);
                            //player.SupportToPlay.
                        }
                    }
            }
            else
            {
                Console.WriteLine($"检验签名失败,{ots.Key},{ots.signature},{ots.address}");
            }
            for (var i = 0; i < notifyMsg.Count; i += 2)
            {
                var url     = notifyMsg[i];
                var sendMsg = notifyMsg[i + 1];
                Console.WriteLine($"url:{url}");
                await Startup.sendMsg(url, sendMsg);
            }
        }
Exemplo n.º 2
0
        internal static async Task GetSubsidize(State s, GetSubsidize getSubsidize)
        {
            Regex r = new Regex("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$");

            if (r.IsMatch(getSubsidize.signature))
            {
                var getPosition = new OrderToSubsidize()
                {
                    c         = "OrderToSubsidize",
                    Key       = s.Key,
                    address   = getSubsidize.address,
                    signature = getSubsidize.signature,
                    value     = getSubsidize.value
                };
                var msg = Newtonsoft.Json.JsonConvert.SerializeObject(getPosition);
                await Startup.sendInmationToUrlAndGetRes(Room.roomUrls[s.roomIndex], msg);
            }

            //throw new NotImplementedException();
        }