You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 1.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Grpc.Core;
  2. using Protobuf;
  3. namespace ClientTest
  4. {
  5. public class Program
  6. {
  7. public static Task Main(string[] args)
  8. {
  9. Thread.Sleep(3000);
  10. Channel channel = new Channel("127.0.0.1:8888", ChannelCredentials.Insecure);
  11. var client = new AvailableService.AvailableServiceClient(channel);
  12. PlayerMsg playerInfo = new();
  13. playerInfo.PlayerId = 0;
  14. playerInfo.PlayerType = PlayerType.StudentPlayer;
  15. playerInfo.StudentType = StudentType.Athlete;
  16. var call = client.AddPlayer(playerInfo);
  17. MoveMsg moveMsg = new();
  18. moveMsg.PlayerId = 0;
  19. moveMsg.TimeInMilliseconds = 100;
  20. moveMsg.Angle = 0;
  21. int tot = 0;
  22. /*while (await call.ResponseStream.MoveNext())
  23. {
  24. var currentGameInfo = call.ResponseStream.Current;
  25. if (currentGameInfo.GameState == GameState.GameStart) break;
  26. }*/
  27. while (true)
  28. {
  29. Thread.Sleep(50);
  30. MoveRes boolRes = client.Move(moveMsg);
  31. if (boolRes.ActSuccess == false) break;
  32. tot++;
  33. if (tot % 10 == 0) moveMsg.Angle += 1;
  34. Console.WriteLine("Move!");
  35. }
  36. return Task.CompletedTask;
  37. }
  38. }
  39. }