Exemplo n.º 1
0
        void BuildClientPolicyCPP()
        {
            Parameter[] newparams;

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildNetPolicyClassParserImpl(msg.Name, "Cmd", newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildNetPolicyClassParserImpl(msg.Name, "C2SEvt", newparams);
                }
            }
        }
Exemplo n.º 2
0
        void BuildMessageIDAccessCPP()
        {
            // Packer interface
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildAccessPropertyNativeImplementation(msg, "Cmd"); NewLine();
                    BuildAccessPropertyNativeImplementation(msg, "Res"); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildAccessPropertyNativeImplementation(msg, "C2SEvt"); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    var msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildAccessPropertyNativeImplementation(msg, "S2CEvt"); NewLine();
                }
            }

            NewLine();
            NewLine();
        }
        // build parser class header
        void BuildGroupStrings()
        {
            StringSet.Add(Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "Cmd");
                    StringSet.Add(msg.Name + "Res");

                    if (msg.Cmd != null)
                    {
                        foreach (var parameter in msg.Cmd)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "C2SEvt");

                    if (msg.Params != null)
                    {
                        foreach (var parameter in msg.Params)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "S2CEvt");

                    if (msg.Params != null)
                    {
                        foreach (var parameter in msg.Params)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        void BuildSendAdapterCPP()
        {
            // Packer interface
            Parameter[] newparams;

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunctionNativeImplementation(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeImplementation(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }

            NewLine();
            NewLine();

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunctionNativeImplementation(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeImplementation(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }
        }
Exemplo n.º 5
0
        void BuildMsgMapImpl()
        {
            NewLine();

            if (AppConfig.GetValue("VariableMapParser", false))
            {
                MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,HandleParseMessageTo> {0};", MappingTableName());
            }
            MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,HandleParseMessageToMessageBase> {0};", MappingToMessageBaseName());

            NewLine();
            OpenSection("void", string.Format("RegisterParser{0}()", Group.Name));

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMsgMap(MsgType.Cmd, "Cmd", msg.Name, msg.Cmd);
                    BuildMsgMap(MsgType.Res, "Res", msg.Name, msg.Res);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMsgMap(MsgType.Evt, "C2SEvt", msg.Name, msg.Params);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMsgMap(MsgType.Evt, "S2CEvt", msg.Name, msg.Params);
                }
            }

            CloseSection();
        }
Exemplo n.º 6
0
        protected virtual void BuildServerServiceH()
        {
            Parameter[] newparams;

            OpenSection("class", string.Format("{0} : public ServerServiceBase", ServiceClassName));
            MatchIndent(); OutStream.WriteLine("public:");
            MatchIndent(); OutStream.WriteLine("// Constructor");
            MatchIndent(); OutStream.WriteLine("{0} ( ServerServiceInformation* pService );", ServiceClassName);
            NewLine();

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    MatchIndent(); OutStream.WriteLine("Result {0}Cmd( {1} );", msg.Name, ParamString(newparams));
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    if (Group.GenParameterRouteContext)
                    {
                        newparams = MakeParametersForEvent(msg.Params);
                    }
                    else
                    {
                        newparams = MakeParameters(MsgType.Evt, msg.Params);
                    }
                    MatchIndent(); OutStream.WriteLine("Result {0}C2SEvt( {1} );", msg.Name, ParamString(newparams));
                }
            }

            NewLine();

            CloseSection();
        }
Exemplo n.º 7
0
        void BuildIClientPolicyH()
        {
            Parameter[] newparams;

            OpenSection("class", string.Format("{0} ", PolicyClassName));
            MatchIndent(); OutStream.WriteLine("private:");
            MatchIndent(1); OutStream.WriteLine("SharedPointerT<MessageEndpoint> m_Endpoint;");
            MatchIndent(); OutStream.WriteLine("public:");
            MatchIndent(); OutStream.WriteLine("// Constructor");
            MatchIndent(); OutStream.WriteLine(
                string.Format("{0} (const SharedPointerT<MessageEndpoint>& pEndpoint ) : m_Endpoint(pEndpoint)", PolicyClassName));
            MatchIndent(); OutStream.WriteLine("{}");
            NewLine();

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    MatchIndent(); OutStream.WriteLine(
                        string.Format("Result {0}Cmd( {1} );", msg.Name, ParamInString(newparams)));
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    MatchIndent(); OutStream.WriteLine(
                        string.Format("Result {0}C2SEvt( {1} );", msg.Name, ParamInString(newparams)));
                }
            }

            NewLine();

            CloseSection();
        }
Exemplo n.º 8
0
        void BuildMessageParserClassCSharp()
        {
            // Packer interface
            Parameter[] newparams;

            MessageCodeIndex = 0;
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildMessageClass(msg, "Cmd", newparams);

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildMessageClass(msg, "Res", newparams); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildMessageClass(msg, "C2SEvt", newparams); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildMessageClass(msg, "S2CEvt", newparams); NewLine();
                }

                MessageCodeIndex++;
            }
        }
Exemplo n.º 9
0
        void BuildServerServiceCPP()
        {
            MatchIndent(); OutStream.WriteLine("{0}::{0}( ServerServiceInformation* pService)", ServiceClassName);
            MatchIndent(1); OutStream.WriteLine(": ServerServiceBase(pService)");
            MatchIndent(); OutStream.WriteLine("{");
            MatchIndent(); OutStream.WriteLine("}");

            NewLine(2);

            Parameter[] newparams;
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildServerServiceMethodImpl(MsgType.Cmd, msg.Cmd, msg.Name, "Cmd", newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    if (Group.GenParameterRouteContext)
                    {
                        newparams = MakeParametersForEvent(msg.Params);
                    }
                    else
                    {
                        newparams = MakeParameters(MsgType.Evt, msg.Params);
                    }
                    BuildServerServiceMethodImpl(MsgType.Evt, msg.Params, msg.Name, "C2SEvt", newparams);
                }
            }
        }
Exemplo n.º 10
0
        // build parser class header
        void BuildGroupDoc()
        {
            Parameter[] newparams;
            string      strClassName    = string.Format("{0}", Group.Name);
            string      policyClassName = PolicyClassName;

            MatchIndent(); OutStream.WriteLine("# Protocol interface class {0}", policyClassName);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildAPIDoc(msg, MakeParameters(MsgType.Cmd, msg.Cmd), MakeParameters(MsgType.Res, msg.Res));
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildAPIDoc(msg, MsgType.Evt, "C2SEvt", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildAPIDoc(msg, MsgType.Evt, "S2CEvt", newparams);
                    NewLine();
                }
            }
        }
Exemplo n.º 11
0
        void BuildMsgMapImpl()
        {
            MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,MessageHandlingFunction> {0};", MappingTableName());
            NewLine();

            OpenSection("void", string.Format("RegisterDebugTrace{0}()", Group.Name));

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMsgMap(MsgType.Cmd, "Cmd", msg.Name, msg.Cmd);
                    BuildMsgMap(MsgType.Res, "Res", msg.Name, msg.Res);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMsgMap(MsgType.Evt, "C2SEvt", msg.Name, msg.Params);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMsgMap(MsgType.Evt, "S2CEvt", msg.Name, msg.Params);
                }
            }

            CloseSection();
        }
Exemplo n.º 12
0
        void BuildMessageIDClassCSharp()
        {
            // Packer interface
            OpenSection("public partial class", "MessageID" + Group.Name);


            MatchIndent(); OutStream.WriteLine("const string NativeDLLName = ");
            MatchIndent(); OutStream.WriteLine("#if UNITY_IOS");
            MatchIndent(); OutStream.WriteLine("    \"__Internal\";");
            MatchIndent(); OutStream.WriteLine("#else");
            MatchIndent(); OutStream.WriteLine("    \"{0}\";", DLL_NAME);
            MatchIndent(); OutStream.WriteLine("#endif");



            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildAccessProperty(msg, "Cmd"); NewLine();
                    BuildAccessProperty(msg, "Res"); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildAccessProperty(msg, "C2SEvt"); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    var msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildAccessProperty(msg, "S2CEvt"); NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildAccessPropertyNativeInterface(msg, "Cmd"); NewLine();
                    BuildAccessPropertyNativeInterface(msg, "Res"); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildAccessPropertyNativeInterface(msg, "C2SEvt"); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    var msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildAccessPropertyNativeInterface(msg, "S2CEvt"); NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");


            CloseSection();
        }
Exemplo n.º 13
0
        void BuildMessageParserClassCPP()
        {
            // Packer interface
            Parameter[] newparams;
            m_MessageCodeIndex = 0;
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMessageIDImpl(msg, MsgType.Cmd, "Cmd");
                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildGetFunctionImpl(msg.Name, "Cmd", newparams);
                    BuildParserImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Cmd", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "Cmd", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "Cmd", msg.Trace.ToString(), newparams);

                    BuildMessageIDImpl(msg, MsgType.Res, "Res");
                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildGetFunctionImpl(msg.Name, "Res", newparams);
                    BuildParserImpl(msg.Name, "Res", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "Res", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "Res", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Res", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Res", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "Res", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "Res", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "Res", msg.Trace.ToString(), newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMessageIDImpl(msg, MsgType.Evt, "C2SEvt");
                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildGetFunctionImpl(msg.Name, "C2SEvt", newparams);
                    BuildParserImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "C2SEvt", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "C2SEvt", msg.Trace.ToString(), newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMessageIDImpl(msg, MsgType.Evt, "S2CEvt");
                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildGetFunctionImpl(msg.Name, "S2CEvt", newparams);
                    BuildParserImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "S2CEvt", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "S2CEvt", msg.Trace.ToString(), newparams);
                }
                m_MessageCodeIndex++;
            }
        }
Exemplo n.º 14
0
        void BuildMessageAdapterClassCSharp()
        {
            // Packer interface
            Parameter[] newparams;

            OpenSection("public class", String.Format("SendMessage{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessage" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunction(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunctionNativeInterface(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();



            OpenSection("public class", String.Format("SendMessageSvr{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessageSvr" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunction(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunctionNativeInterface(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();
        }