1+ using Grpc . Core ;
2+ using Protobuf ;
3+
4+ namespace ClientTest
5+ {
6+ public class Program
7+ {
8+ public static Task Main ( string [ ] args )
9+ {
10+ if ( args . Length < 2 )
11+ {
12+ Console . WriteLine ( "Please provide both CharacterId and TeamId as arguments." ) ;
13+ return Task . CompletedTask ;
14+ }
15+ if ( ! int . TryParse ( args [ 0 ] , out int characterId ) )
16+ {
17+ Console . WriteLine ( "Invalid CharacterId. Please provide a valid integer." ) ;
18+ return Task . CompletedTask ;
19+ }
20+
21+ if ( ! int . TryParse ( args [ 1 ] , out int teamId ) )
22+ {
23+ Console . WriteLine ( "Invalid TeamId. Please provide a valid integer." ) ;
24+ return Task . CompletedTask ;
25+ }
26+ Thread . Sleep ( 3000 ) ;
27+ Channel channel = new ( "127.0.0.1:8888" , ChannelCredentials . Insecure ) ;
28+ var client = new AvailableService . AvailableServiceClient ( channel ) ;
29+ CharacterMsg playerInfo = new ( )
30+ {
31+ CharacterId = characterId ,
32+ TeamId = teamId ,
33+ CharacterType = teamId == 1 ? CharacterType . JiuLing : CharacterType . TangSeng ,
34+ SideFlag = teamId
35+ } ;
36+ var call = client . AddCharacter ( playerInfo ) ;
37+ MoveMsg moveMsg = new ( )
38+ {
39+ CharacterId = 1 ,
40+ TeamId = 0 ,
41+ TimeInMilliseconds = 100 ,
42+ Angle = 0
43+ } ;
44+ int tot = 0 ;
45+ while ( call . ResponseStream . MoveNext ( ) . Result )
46+ {
47+ var currentGameInfo = call . ResponseStream . Current ;
48+ if ( currentGameInfo . GameState == GameState . GameStart ) break ;
49+ }
50+ while ( true )
51+ {
52+ Thread . Sleep ( 50 ) ;
53+
54+ MoveRes boolRes = client . Move ( moveMsg ) ;
55+ //if (boolRes.ActSuccess == false) break;
56+ tot ++ ;
57+ if ( tot % 10 == 0 ) moveMsg . Angle += 1 ;
58+ }
59+ return Task . CompletedTask ;
60+ }
61+ }
62+ }
0 commit comments