示例#1
0
        protected override void AddSubParsersInternal()
        {
            base.AddSubParsersInternal();

            // GIM
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.GIM, (int)FF_AppId_TargetIds.GIM,
                                       new FFParser_Tgt_MC300_GIM_G2H());

            // Status Block (GMU Events)
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.StatusBlock, (int)FF_AppId_TargetIds.StatusBlock,
                                       new FFParser_Tgt_MC300_GMUEvent_G2H());

            // Meters
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.MeterBlock, (int)FF_AppId_TargetIds.MeterBlock,
                                       new FFParser_Tgt_MC300_AccountingMeters_G2H());

            // Security
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.Security, true, (int)FF_GmuId_TargetIds.Security, true),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.Security, true, (int)FF_AppId_TargetIds.Security, true),
                                       new FFParser_Tgt_MC300_Security_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.ECash, true, (int)FF_GmuId_TargetIds.Security, true),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.ECash, true, (int)FF_AppId_TargetIds.Security, true),
                                       new FFParser_Tgt_MC300_Security_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.Security, true, (int)FF_GmuId_TargetIds.Security, false),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.Security, true, (int)FF_AppId_TargetIds.Security, false),
                                       new FFParser_Tgt_MC300_Security_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.ECash, true, (int)FF_GmuId_TargetIds.Security, false),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.ECash, true, (int)FF_AppId_TargetIds.Security, false),
                                       new FFParser_Tgt_MC300_Security_G2H());

            // Tickets
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.Tickets, (int)FF_AppId_TargetIds.Tickets,
                                       new FFParser_Tgt_MC300_TicketInfo_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateRequestResponseId((int)FF_GmuId_TargetIds.Tickets, true),
                                       FreeformHelper.CreateRequestResponseId((int)FF_AppId_TargetIds.Tickets, true),
                                       new FFParser_Tgt_MC300_TicketInfo_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.Tickets, true, (int)FF_GmuId_TargetIds.Security, true),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.Tickets, true, (int)FF_AppId_TargetIds.Security, true),
                                       new FFParser_Tgt_MC300_Encrypted_G2H());

            // ECash
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.ECash, (int)FF_AppId_TargetIds.ECash,
                                       new FFParser_Tgt_MC300_EFT_G2H());
            this.AddBufferEntityParser(FreeformHelper.CreateCombinedId((int)FF_GmuId_SessionIds.ECash, false, (int)FF_GmuId_TargetIds.Security, true),
                                       FreeformHelper.CreateCombinedId((int)FF_AppId_SessionIds.ECash, false, (int)FF_AppId_TargetIds.Security, true),
                                       new FFParser_Tgt_MC300_Encrypted_G2H());

            // GMU Var Action
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.GMUVariableAction, (int)FF_AppId_TargetIds.GMUVariableAction,
                                       new FFParser_Tgt_MC300_GMUVarAction_G2H());

            // Game Message
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.GameMessage, (int)FF_AppId_TargetIds.GameMessage,
                                       new FFParser_Tgt_MC300_GameMessage_G2H());

            // PID
            this.AddBufferEntityParser((int)FF_GmuId_TargetIds.PID, (int)FF_AppId_TargetIds.PID,
                                       new FFParser_Tgt_MC300_PID_G2H());
        }
示例#2
0
        internal override void ParseEntityInternal(IFreeformEntity entity, ref List <byte> buffer)
        {
            IFreeformEntity_MsgTgt tgt  = entity as IFreeformEntity_MsgTgt;
            IFreeformEntity_MsgTgt tgt2 = tgt;

            if (tgt2 != null)
            {
                // has raw data inside the target
                if (tgt2 is IFFTgt_Override)
                {
                    buffer.AddRange(tgt2.ToRawData());
                    return;
                }

                int       gmuParserId   = this.GetTargetId(tgt, out tgt2);
                int       gmuTargetId   = gmuParserId.ExtractCombinedId();
                bool      isSecured     = tgt2.IsSecured;
                bool      hasSubTargets = this.HasSubTargets;
                byte[]    buffer2       = null;
                IFFParser parser        = this;
                IFFParser parserSecured = null;

                FFParserItem parserItem = this.GetParserItem(null, gmuParserId);
                if (parserItem == null)
                {
                    if (tgt2.Parent != null &&
                        tgt2.Parent is IFreeformEntity_Msg)
                    {
                        int id = FreeformHelper.CreateCombinedId(tgt2.Parent.UniqueEntityId.GetGmuIdInt8(), gmuParserId);
                        parserItem = this.GetParserItem(null, id);
                    }
                }

                // found?
                if (parserItem != null)
                {
                    // parser
                    IFFParser parser2 = parserItem.GetParser(this.FlowInitiation);
                    if (parser2 != null)
                    {
                        if (tgt2.Targets != null &&
                            tgt2.Targets.Count > 0)
                        {
                            buffer2 = parser2.ParseTarget(tgt2);
                        }
                        else
                        {
                            parser = parser2;
                        }
                    }

                    // secured parser
                    if (isSecured)
                    {
                        int          securityId  = FreeformHelper.CreateCombinedId(entity.Parent as IFreeformEntity_Msg, SECURITY_ID, false);
                        FFParserItem parserItem2 = this.GetParserItem(null, securityId);
                        if (parserItem2 != null)
                        {
                            parserSecured = parserItem2.GetParser(this.FlowInitiation);
                        }
                    }
                }

                bool skipTargetInfo = parser.SkipTargetInfo;
                if (buffer2 == null)
                {
                    List <byte> data = new List <byte>();
                    parser.GetTargetData(tgt2, ref data);
                    buffer2 = data.ToArray();
                }

                // encrypt the target
                if (isSecured &&
                    parserSecured != null)
                {
                    List <byte> bufferToEncrypt = new List <byte>();
                    this.AddTargetToBuffer(ref bufferToEncrypt, (byte)gmuTargetId, buffer2, true, false);

                    parserSecured.GetTargetData(tgt2, ref bufferToEncrypt);
                    buffer2        = bufferToEncrypt.ToArray();
                    gmuTargetId    = SECURITY_ID;
                    hasSubTargets  = true;
                    skipTargetInfo = false;
                }

                this.AddTargetToBuffer(ref buffer, (byte)gmuTargetId, buffer2, hasSubTargets, skipTargetInfo);
            }
        }