public void ProcessLBDCommandQuene()
        {
            while (true)
            {
                if (lbcmdQueue.Count > 0)
                {
                    Msg.LBDBaseMsg msg = null;
                    if (lbcmdQueue.TryDequeue(out msg))
                    {
                        try
                        {
                            if (messageHandler.ContainsKey(msg.msgType))
                            {
                                messageHandler[msg.msgType](msg);
                            }
                            else
                            {
                                Console.WriteLine($"MessageHandler Not Found Type {msg.msgType.Name}");
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Error($"exception={e.ToString()}");
                            break;
                        }
                    }
                    else
                    {
                        logger.Warn($"lbcmdQueue Dequeue fail QueueCount={lbcmdQueue.Count}");
                    }
                }

                Thread.Sleep(1);
            }
        }
Exemplo n.º 2
0
        public TcpMsg.Error SendMint()
        {
            if (reqhttpData == null)
            {
                return(TcpMsg.Error.InternalError);
            }

            user.stateType = userStateType;
            LBD.LBDApiManager.Instance.AddLBDCmd(reqhttpData);
            user.processShopSlot = this;
            reqhttpData          = null;
            userStateType        = UserStateType.None;

            return(TcpMsg.Error.None);
        }
Exemplo n.º 3
0
 protected void SetMint(LBD.Msg.LBDBaseMsg req, UserStateType userStateType)
 {
     this.reqhttpData   = req;
     this.userStateType = userStateType;
 }
        public override TcpMsg.Error Buy(User user)
        {
            var consumeState = ConsumeCurrency(user.tblUser.address, user.tblUser.level);

            if (consumeState == Currency.ConsumeState.ConsumeState_Falied)
            {
                return(TcpMsg.Error.ShopBuyFailed);
            }

            if (product_currency.currencyType == Currency.CurrencyType.Currency_token)
            {
                LBD.Msg.LBDBaseMsg req = null;
                if (data_price.fungibleType == Resource.FungibleType.Fungible)
                {
                    req = new LBD.Msg.LBDMsg_MintFungible()
                    {
                        uid       = UID,
                        guid      = user.Id.ToString(),
                        toAddr    = string.Empty,
                        toUserId  = user.lineUID,
                        tokenType = product_currency.TokenType(),
                        amount    = (int)data_shop.sellCount
                    };

                    /* TODO : belldan
                     * Operator Addr 에 Mint 후 User에게 지급 할때 사용
                     * req = new LBD.Msg.LBDMsg_Wallet_Fungible_Transfer()
                     * {
                     *  uid = UID,
                     *  guid = user.Id.ToString(),
                     *  fromAddr = Setting.ProgramSetting.Instance.lbdInfo.operatorAddr,
                     *  fromSecret = Setting.ProgramSetting.Instance.lbdInfo.secretKey,
                     *  toAddr = string.Empty,
                     *  toUserId = user.lineUID,
                     *  tokenType = product_currency.TokenType(),
                     *  amount = (int)data_shop.sellCount
                     * };
                     */
                }
                else if (data_price.fungibleType == Resource.FungibleType.ServiceToken)
                {
                    req = new LBD.Msg.LBDMsg_TransferServiceToken()
                    {
                        uid        = UID,
                        guid       = user.Id.ToString(),
                        contractId = product_currency.TokenType(),
                        fromAddr   = Setting.ProgramSetting.Instance.lbdInfo.operatorAddr,
                        fromSecret = Setting.ProgramSetting.Instance.lbdInfo.secretKey,
                        toAddr     = string.Empty,
                        toUserId   = user.lineUID,
                        amount     = (int)data_shop.sellCount
                    };
                }
                else
                {
                    return(TcpMsg.Error.ShopBuyFailed);
                }

                SetMint(req, UserStateType.BuyFungible);

                if (consumeState == Currency.ConsumeState.ConsumeState_Done)
                {
                    SendMint();
                }
            }
            else
            {
                if (consumeState == Currency.ConsumeState.ConsumeState_Done)
                {
                    OnBuy(new Dictionary <string, Int64>()
                    {
                        { product_currency.TokenType(), data_shop.sellCount }
                    }, user);
                }
            }

            logger.Debug($"Buy UserID={UID} ShopType={data_shop.shopType} SlotIndex={data_shop.slotIndex} consumeState={consumeState}");

            return(TcpMsg.Error.None);
        }
 public void AddLBDCmd(Msg.LBDBaseMsg data)
 {
     lbcmdQueue.Enqueue(data);
 }