SignallingService.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections.Generic;
  2. using Blue;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Linq;
  5. using UnityEngine;
  6. public class SignallingService : ISignallingService
  7. {
  8. public void OnInit()
  9. {
  10. this.RegisterEvent<GetContactsSuccessEvent>(GetContactsSuccess);
  11. }
  12. public void GetContacts()
  13. {
  14. CoroutineSystem.Instance.StartCoroutine(
  15. HttpTool.Instance.SendHttp(HttpActionLang.signal_contact, "", message =>
  16. {
  17. JObject jobject = JObject.Parse(message);
  18. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()) && !string.IsNullOrEmpty(jobject["data"]["list"].ToString()))
  19. {
  20. this.SendEvent(new GetContactsSuccessEvent() { jsonString = jobject["data"]["list"].ToString() });
  21. }
  22. }, "application/x-www-form-urlencoded"));
  23. }
  24. #region 事件
  25. private void GetContactsSuccess(GetContactsSuccessEvent e)
  26. {
  27. List<ContactsInfo> mContactsInfoList = JsonConvert.DeserializeObject<List<ContactsInfo>>(e.jsonString);
  28. Debug.LogError($"获取联系人:{e.jsonString}");
  29. }
  30. #endregion
  31. }