@@ -13,10 +13,12 @@ public void Run(MessageInfoList messageInfoList, string outputPath, string names
13
13
StringBuilder sb = new StringBuilder ( ) ;
14
14
sb . Append ( "import IRequestMessage from \" ../network/IRequestMessage\" ;\n " ) ;
15
15
sb . Append ( "import IResponseMessage from \" ../network/IResponseMessage\" ;\n " ) ;
16
+ sb . Append ( "import INotifyMessage from \" ../network/INotifyMessage\" ;\n " ) ;
17
+ sb . Append ( "import IHeartBeatMessage from \" ../network/IHeartBeatMessage\" ;\n " ) ;
16
18
sb . Append ( "import MessageObject from \" ../network/MessageObject\" ;\n " ) ;
17
- sb . Append ( "import RegisterRequestMessageClass from \" ../network/RegisterRequestMessageClass \" ;\n " ) ;
18
- sb . Append ( "import RegisterResponseMessageClass from \" ../network/RegisterResponseMessageClass \" ; \n " ) ;
19
- // sb.Append($"namespace {namespaceName } {'{'}\n");
19
+ sb . Append ( "import ProtoMessageHelper from \" ../network/ProtoMessageHelper \" ;\n " ) ;
20
+ sb . AppendLine ( ) ;
21
+ sb . Append ( $ "export namespace { messageInfoList . ModuleName } { '{' } \n ") ;
20
22
21
23
foreach ( var operationCodeInfo in messageInfoList . Infos )
22
24
{
@@ -42,14 +44,14 @@ public void Run(MessageInfoList messageInfoList, string outputPath, string names
42
44
sb . Append ( $ "\t /// <summary>\n ") ;
43
45
sb . Append ( $ "\t /// { operationCodeInfo . Description } \n ") ;
44
46
sb . Append ( $ "\t /// </summary>\n ") ;
45
- if ( operationCodeInfo . IsRequest )
46
- {
47
- sb . Append ( $ "\t @RegisterRequestMessageClass({ operationCodeInfo . Opcode } )\n ") ;
48
- }
49
- else
50
- {
51
- sb . Append ( $ "\t @RegisterResponseMessageClass({ operationCodeInfo . Opcode } )\n ") ;
52
- }
47
+ // if (operationCodeInfo.IsRequest)
48
+ // {
49
+ // sb.Append($"\t@RegisterRequestMessageClass({operationCodeInfo.Opcode})\n");
50
+ // }
51
+ // else
52
+ // {
53
+ // sb.Append($"\t@RegisterResponseMessageClass({operationCodeInfo.Opcode})\n");
54
+ // }
53
55
54
56
if ( string . IsNullOrEmpty ( operationCodeInfo . ParentClass ) )
55
57
{
@@ -59,6 +61,26 @@ public void Run(MessageInfoList messageInfoList, string outputPath, string names
59
61
{
60
62
// sb.AppendLine($"\t[MessageTypeHandler({operationCodeInfo.Opcode})]");
61
63
sb . AppendLine ( $ "\t export class { operationCodeInfo . Name } extends MessageObject implements { operationCodeInfo . ParentClass } { '{' } ") ;
64
+ sb . AppendLine ( ) ;
65
+
66
+ sb . Append ( $ "\t \t public static register(): void{ '{' } \n ") ;
67
+ if ( operationCodeInfo . IsRequest )
68
+ {
69
+ sb . Append ( $ "\t \t \t ProtoMessageHelper.registerReqMessage('{ messageInfoList . ModuleName } .{ operationCodeInfo . Name } ', { ( messageInfoList . Module << 16 ) + operationCodeInfo . Opcode } );\n ") ;
70
+ }
71
+ else
72
+ {
73
+ sb . Append ( $ "\t \t \t ProtoMessageHelper.registerRespMessage('{ messageInfoList . ModuleName } .{ operationCodeInfo . Name } ', { ( messageInfoList . Module << 16 ) + operationCodeInfo . Opcode } );\n ") ;
74
+ }
75
+
76
+ sb . Append ( $ "\t \t { '}' } \n ") ;
77
+
78
+
79
+ sb . Append ( $ "\t \t public get PackageName(): string{ '{' } \n ") ;
80
+ sb . Append ( $ "\t \t \t return '{ messageInfoList . ModuleName } .{ operationCodeInfo . Name } ';\n ") ;
81
+ sb . Append ( $ "\t \t { '}' } \n ") ;
82
+
83
+ sb . AppendLine ( ) ;
62
84
}
63
85
64
86
foreach ( var operationField in operationCodeInfo . Fields )
@@ -84,15 +106,12 @@ public void Run(MessageInfoList messageInfoList, string outputPath, string names
84
106
}
85
107
}
86
108
87
- sb . Append ( $ "\t \t public static get PackageName(): string{ '{' } \n ") ;
88
- sb . Append ( $ "\t \t \t return '{ namespaceName } .{ operationCodeInfo . Name } ';\n ") ;
89
- sb . Append ( $ "\t \t { '}' } \n ") ;
90
109
91
110
sb . AppendLine ( "\t }\n " ) ;
92
111
}
93
112
}
94
113
95
- // sb.Append("}\n");
114
+ sb . Append ( "}\n " ) ;
96
115
97
116
File . WriteAllText ( messageInfoList . OutputPath + ".ts" , sb . ToString ( ) , Encoding . UTF8 ) ;
98
117
}
@@ -139,5 +158,33 @@ static string ConvertType(string type)
139
158
140
159
return typeCs ;
141
160
}
161
+
162
+
163
+ public void Post ( List < MessageInfoList > operationCodeInfo , string launcherOptionsOutputPath )
164
+ {
165
+ StringBuilder stringBuilder = new StringBuilder ( ) ;
166
+
167
+ foreach ( var messageInfoList in operationCodeInfo )
168
+ {
169
+ stringBuilder . AppendLine ( $ "import {{ { messageInfoList . ModuleName } }} from \" ./{ messageInfoList . ModuleName } _{ messageInfoList . Module } \" ;") ;
170
+ }
171
+
172
+ stringBuilder . AppendLine ( ) ;
173
+ stringBuilder . AppendLine ( "export default class ProtoMessageRegister {\n public static register(): void{" ) ;
174
+
175
+ foreach ( var messageInfoList in operationCodeInfo )
176
+ {
177
+ foreach ( var messageInfo in messageInfoList . Infos )
178
+ {
179
+ if ( ! string . IsNullOrEmpty ( messageInfo . ParentClass ) )
180
+ {
181
+ stringBuilder . AppendLine ( $ "\t \t { messageInfoList . ModuleName } .{ messageInfo . Name } .register();") ;
182
+ }
183
+ }
184
+ }
185
+
186
+ stringBuilder . AppendLine ( " }\n }" ) ;
187
+ File . WriteAllText ( launcherOptionsOutputPath + "/ProtoMessageRegister.ts" , stringBuilder . ToString ( ) , Encoding . UTF8 ) ;
188
+ }
142
189
}
143
190
}
0 commit comments