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
123456789101112131415161718192021222324252627282930313233343536
  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. Channel channel = new Channel("0.0.0.0:8888", ChannelCredentials.Insecure);
  10. var client = new AvailableService.AvailableServiceClient(channel);
  11. PlayerMsg playerInfo = new();
  12. playerInfo.PlayerId = Convert.ToInt32(args[0]);
  13. playerInfo.PlayerType = (PlayerType)Convert.ToInt32(args[1]);
  14. var call = client.AddPlayer(playerInfo);
  15. while (await call.ResponseStream.MoveNext())
  16. {
  17. var currentGameInfo = call.ResponseStream.Current;
  18. if (playerInfo.PlayerType == PlayerType.HumanPlayer)
  19. {
  20. for (int i = 0; i < currentGameInfo.HumanMessage.Count; i++)
  21. {
  22. Console.WriteLine($"Human is at ({currentGameInfo.HumanMessage[i].X}, {currentGameInfo.HumanMessage[i].Y})");
  23. }
  24. }
  25. if (playerInfo.PlayerType == PlayerType.ButcherPlayer)
  26. {
  27. for (int i = 0; i < currentGameInfo.ButcherMessage.Count; i++)
  28. {
  29. Console.WriteLine($"Butcher is at ({currentGameInfo.ButcherMessage[i].X}, {currentGameInfo.ButcherMessage[i].Y})");
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }