MessageHelper.cs 872 B

12345678910111213141516171819202122232425262728293031
  1. using ET;
  2. using System;
  3. namespace GFGGame
  4. {
  5. public static class MessageHelper
  6. {
  7. public static async ETTask<IResponse> SendToServer(IActorLocationRequest request, bool showError = true)
  8. {
  9. IResponse response = null;
  10. Session session = GameGlobal.zoneScene.GetComponent<SessionComponent>().Session;
  11. try
  12. {
  13. response = await session.Call(request);
  14. if (showError)
  15. {
  16. if (response.Error != ErrorCode.ERR_Success)
  17. {
  18. ErrorCodeController.Handler(response.Error);
  19. }
  20. }
  21. return response;
  22. }
  23. catch(Exception e)
  24. {
  25. Log.Error(e.ToString());
  26. return null;
  27. }
  28. }
  29. }
  30. }