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.5 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Grpc.Core;
  2. using Protobuf;
  3. namespace ClientTest
  4. {
  5. public class Program
  6. {
  7. public static async 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.StudentType = StudentType.NullStudentType;
  15. var call = client.AddPlayer(playerInfo);
  16. MoveMsg moveMsg = new();
  17. moveMsg.PlayerId = 0;
  18. moveMsg.TimeInMilliseconds = 100;
  19. moveMsg.Angle = 0;
  20. while (true)
  21. {
  22. Console.ReadLine();
  23. client.Move(moveMsg);
  24. Console.WriteLine("Move!");
  25. }
  26. while (await call.ResponseStream.MoveNext())
  27. {
  28. Console.WriteLine("hi");
  29. var currentGameInfo = call.ResponseStream.Current;
  30. for (int i = 0; i < currentGameInfo.ObjMessage.Count; i++)
  31. {
  32. if (currentGameInfo.ObjMessage[i].MessageOfObjCase == MessageOfObj.MessageOfObjOneofCase.StudentMessage)
  33. Console.WriteLine($"Human is at ({currentGameInfo.ObjMessage[i].StudentMessage.X}, {currentGameInfo.ObjMessage[i].StudentMessage.Y})");
  34. }
  35. }
  36. }
  37. }
  38. }