Esempio n. 1
0
        public static int GetMessageId(TBase message)
        {
            if (CanSupportMessage(message))
            {
                return(REQ_MSG_ID[message.GetType()]);
            }

            return(-1);
        }
        public static int GetMessageId(TBase message)
        {
            if (CanSupportMessage(message))
            {
                return REQ_MSG_ID[message.GetType()];
            }

            return -1;
        }
Esempio n. 3
0
        public Header HeaderLookup(TBase tbase)
        {
            if (tbase == null)
            {
                throw new Exception("tbase must not be null");
            }
            if (tbase is TSpan)
            {
                return(SPAN_HEADER);
            }
            if (tbase is TSpanChunk)
            {
                return(SPANCHUNK_HEADER);
            }
            if (tbase is TSpanEvent)
            {
                return(SPANEVENT_HEADER);
            }
            if (tbase is TAgentInfo)
            {
                return(AGENT_INFO_HEADER);
            }
            if (tbase is TAgentStat)
            {
                return(AGENT_STAT_HEADER);
            }
            if (tbase is TAgentStatBatch)
            {
                return(AGENT_STAT_BATCH_HEADER);
            }
            if (tbase is TSqlMetaData)
            {
                return(SQLMETADATA_HEADER);
            }
            if (tbase is TApiMetaData)
            {
                return(APIMETADATA_HEADER);
            }
            if (tbase is TResult)
            {
                return(RESULT_HEADER);
            }
            if (tbase is TStringMetaData)
            {
                return(STRINGMETADATA_HEADER);
            }
            //if (tbase is NetworkAvailabilityCheckPacket) {
            //    return NETWORK_CHECK_HEADER;
            //}

            throw new TException("Unsupported Type" + tbase.GetType());
        }
Esempio n. 4
0
    protected override void Beat()
    {
        List <TBase> updateList = null;

        while (true)
        {
            AbstractBusinessObject obj = UpdateManager.Instance.Poll();
            if (obj == null)
            {
                break;
            }
            ICharDataConverter converter = ConverterManager.Instance.FindConverter(obj.GetType());
            if (converter == null)
            {
                Debuger.LogError(string.Format("not found converter. type:{0}", obj.GetType()));
                continue;
            }
            TBase info = converter.Convert(obj);
            obj.ResetModify();
            if (info == null)
            {
                Debuger.LogError(string.Format("convert result is null. type:{0}", obj.GetType()));
                continue;
            }
            if (updateList == null)
            {
                updateList = new List <TBase>();
            }
            updateList.Add(info);
        }
        if (updateList != null)
        {
            CacheKeyInfo keyInfo = CacheKeyContants.CHAR_DATA_SNAPSHOT_KEY.BuildCacheInfo(PlayerManager.Instance.GetCharBaseData().CharId);

            CharacterDataSnapshot data = CacheManager.GetInsance().Get(keyInfo) as CharacterDataSnapshot;

            if (data == null)
            {
                data          = new CharacterDataSnapshot();
                data.Version  = 0L;
                data.DataList = updateList;
            }
            else
            {
                data.Version += 1;
                List <TBase> delList = new List <TBase>();
                for (int i = 0; i < updateList.Count; i++)
                {
                    TBase newTbase = updateList[i];
                    for (int j = 0; j < data.DataList.Count; j++)
                    {
                        if (newTbase.GetType() == data.DataList[j].GetType())
                        {
                            data.DataList[j] = newTbase;
                            delList.Add(newTbase);
                            break;
                        }
                    }
                }
                foreach (TBase delTbase in delList)
                {
                    updateList.Remove(delTbase);
                }
                if (updateList.Count > 0)
                {
                    data.DataList.AddRange(updateList);
                }
            }
            CacheManager.GetInsance().Set(keyInfo, data);
        }
    }
Esempio n. 5
0
 public static bool CanSupportMessage(TBase message)
 {
     return(REQ_MSG_ID.ContainsKey(message.GetType()));
 }
Esempio n. 6
0
        public static EntityObject ConvertToEntityObject(TBase input)
        {
            if (input.GetType() == typeof(TConfiguration))
            {
                return(ConvertToConfiguration(input as TConfiguration));
            }
            else if (input.GetType() == typeof(TCustomer))
            {
                return(ConvertToCustomer(input as TCustomer));
            }
            else if (input.GetType() == typeof(TOrder))
            {
                if ((input as TOrder).Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    return(ConvertToRegualrOrder(input as TOrder));
                }
                else
                {
                    return(ConvertToIrregularOrder(input as TOrder));
                }
            }
            else if (input.GetType() == typeof(TRegularOrder))
            {
                return(ConvertToRegualrOrder(input as TRegularOrder));
            }
            else if (input.GetType() == typeof(TIrregularOrder))
            {
                return(ConvertToIrregularOrder(input as TIrregularOrder));
            }
            else if (input.GetType() == typeof(TOrderItem))
            {
                return(ConvertToOrderItem(input as TOrderItem));
            }
            else if (input.GetType() == typeof(TTicketPrice))
            {
                return(ConvertToPriceTicket(input as TTicketPrice));
            }
            else if (input.GetType() == typeof(TTransportPrice))
            {
                return(ConvertToPriceTransport(input as TTransportPrice));
            }
            else if (input.GetType() == typeof(TSaleTicketDate))
            {
                return(ConvertToSaleTicketDate(input as TSaleTicketDate));
            }
            else if (input.GetType() == typeof(TTicket))
            {
                return(ConvertToTicket(input as TTicket));
            }
            else if (input.GetType() == typeof(TGuaranteeFee))
            {
                return(ConvertToGuaranteeFee(input as TGuaranteeFee));
            }
            else if (input.GetType() == typeof(TBus))
            {
                return(ConvertToBus(input as TBus));
            }
            else if (input.GetType() == typeof(TTour))
            {
                return(ConvertToTour(input as TTour));
            }
            else if (input.GetType() == typeof(TUser))
            {
                return(ConvertToUser(input as TUser));
            }

            return(null);
        }
 public static bool CanSupportMessage(TBase message)
 {
     return REQ_MSG_ID.ContainsKey(message.GetType());
 }
Esempio n. 8
0
        /// <summary>
        /// send msg to server
        /// </summary>
        /// <param name="msgContent"></param>
        public void SendMessage(TBase msgContent)
        {
            var msg = new ThriftCSMessage(msgContent);
            var bytes = msg.Encode();
            if (bytes == null || bytes.Length <= 0)
            {
                Logger.LogError("send data is null or length is 0, msg type = " + msgContent.GetType().ToString());
                return;
            }

            // TODO Encrypt Message Data
            StartSendMsg(bytes);
        }