Ejemplo n.º 1
0
 public override void Update()
 {
     UpdataEvent?.Invoke();
     if (Input.anyKey)
     {
     }
 }
Ejemplo n.º 2
0
        private void MQTTService_UpdataEvent(string obj)
        {
            if (obj != null)
            {
                if (obj == "getBaseInfo")
                {
                    //刷新
                    GetContract();
                    return;
                }

                //挂牌信息
                var b1 = Helper.Deserialize <OneListedResponse>(obj);

                if (b1.Success && b1.Result != null && CommodityDataDy != null)
                {
                    int       type = 2;
                    OneListed cd   = b1.Result;
                    if (cd != null && !HttpService.JudgmentBlack(cd.PublisherId))
                    {
                        if (cd.id != null)
                        {
                            if (CommodityDataDy.ContainsKey(cd.id))
                            {
                                //更新
                                CommodityDataDy[cd.id].Update(cd);
                                type = 2;//更新
                            }
                            else
                            {
                                type = cd.transType;
                                CommodityDataDy.Add(cd.id, cd);
                            }
                            UpdataCommodityInfoEvent?.Invoke(cd, type);
                        }
                    }
                    return;
                }

                //if (b1.Result.TransStatusName == "摘牌")
                //{
                //    //摘牌
                //    var b2 = Helper.Deserialize<DelistBrandOrderResponseArguments>(obj);
                //    if (b2.data != null)
                //    {
                //        UpdataDelistingEvent?.Invoke(b2.data);
                //        return;
                //    }
                //}
                ////核销
                //var b3 = Helper.Deserialize<DelistBrandVerifyResponseArguments>(obj);
                //if (b3.Success && b3.data != null)
                //{
                //    NoticeWriteOffEvent?.Invoke(b3.data);
                //}
                ////撤牌
                //var b4 = Helper.Deserialize<ActionOrderResponseArguments>(obj);
                //if (b4.Success && b4.result != null)
                //{
                //    NoticeWithdrawTheCard?.Invoke(b4.result);
                //}
                UpdataEvent?.Invoke(obj);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 订阅主题消息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void M_mqttClient_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
 {
     if (e.Topic == "market")
     {
         //if (DataManager.Instance.ContractData != null)
         {
             byte[] bs = e.Message;
             // 计算出时时间点ID
             long timeId = byteArrayToLong(bs, 3, 0);
             // 计算出实际时间戳
             //long truthTime = DataManager.Instance.ContractData.today9 + timeId * 500;
             // 品类 转成字符 例:cu1710 al1711
             string code = Encoding.Default.GetString(bs, 3, 6);
             var    d2   = DataManager.Instance.GetContractLastPrice(code);
             if (d2 != null)
             {
                 var d1 = DataManager.Instance.GetContractBasePrice(d2.category, code);
                 if (d1 != null)
                 {
                     //md.timeId = timeId;
                     //md.truthTime = truthTime;
                     //md.category = category;
                     float f;
                     float.TryParse(d1.lowestPrice, out f);
                     // 申买价
                     d2.bidPrice = byteArrayToLong(bs, 3, 9) / 100 + f;
                     // 申卖价
                     d2.askPrice = byteArrayToLong(bs, 3, 12) / 100 + f;
                     // 最新价
                     d2.lastPrice = byteArrayToLong(bs, 3, 15) / 100 + f;
                     UpdataMarketDataEvent?.Invoke(d2);
                 }
                 //else
                 //{
                 //    ContractLastPrice md = new ContractLastPrice();
                 //    //md.timeId = timeId;
                 //    //md.truthTime = truthTime;
                 //    float f;
                 //    float.TryParse(d1.preSettlementPrice, out f);
                 //    md.category = category;
                 //    // 申买价
                 //    md.bidPrice = byteArrayToLong(bs, 3, 9) / 100 + f;
                 //    // 申卖价
                 //    md.askPrice = byteArrayToLong(bs, 3, 12) / 100 +f;
                 //    // 最新价
                 //    md.lastPrice = byteArrayToLong(bs, 3, 15) / 100 + f;
                 //    DataManager.Instance.AddContractLastPrice(md);
                 //    UpdataMarketDataEvent?.Invoke(md);
                 //}
             }
         }
     }
     else if (e.Topic == "trans_list_topic")
     {
         byte[] bs   = e.Message;
         string data = Encoding.UTF8.GetString(bs);
         try
         {
             UpdataEvent?.Invoke(data);
         }
         catch (Exception err)
         {
             Logger.LogError(err.ToString());
         }
     }
     else if (e.Topic == "command")
     {
         byte[] bs   = e.Message;
         string data = Encoding.UTF8.GetString(bs);
         try
         {
             UpdataEvent?.Invoke(data);
         }
         catch (Exception err)
         {
             Logger.LogError(err.ToString());
         }
     }
     else if (e.Topic == m_topic)
     {
         byte[] bs   = e.Message;
         string data = Encoding.UTF8.GetString(bs);
         try
         {
             //核销
             var b3 = Helper.Deserialize <WriteOffResponse>(data);
             if (b3.Success)
             {
                 if (b3.data != null)
                 {
                     NoticeWriteOffEvent?.Invoke(b3.data);
                 }
                 else if (b3.result != null)
                 {
                     NoticeWriteOffEvent?.Invoke(b3.result);
                 }
             }
         }
         catch (Exception err)
         {
             Logger.LogError(err.ToString());
         }
     }
 }