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.

MessageReceiver.cs 1.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Grpc.Core;
  5. using Google.Protobuf;
  6. using Protobuf;
  7. using System.Data;
  8. //using UnityEditor.U2D.Path;
  9. public class MessageReceiver : MonoBehaviour
  10. {
  11. private bool isMap;
  12. // Start is called before the first frame update
  13. async void Start()
  14. {
  15. var channel = new Channel("127.0.0.1:8888", ChannelCredentials.Insecure);
  16. var client = new AvailableService.AvailableServiceClient(channel);
  17. PlayerMsg msg = new PlayerMsg();
  18. msg.PlayerType = PlayerType.StudentPlayer;
  19. msg.PlayerId = 0;
  20. isMap = true;
  21. map = null;
  22. var response = client.AddPlayer(msg);
  23. while (await response.ResponseStream.MoveNext())
  24. {
  25. var responseVal = response.ResponseStream.Current;
  26. if (isMap)
  27. {
  28. map = responseVal.ObjMessage[0].MapMessage;
  29. //Debug.Log(map.ToString());
  30. isMap = false;
  31. }
  32. }
  33. }
  34. // Update is called once per frame
  35. void Update()
  36. {
  37. }
  38. public static MessageOfMap map;
  39. }