using System.Threading.Tasks; using Ragdoll; using Newtonsoft.Json; namespace HttpApi { public class Api { private static string _dataUrl = "http://47.114.170.126:19996/cock/"; private static string _msgUrl = "http://test.static.cxhy.cn:16002/"; private static volatile string _session; public static async Task Auth(string token) { var httpObj = new AuthObj { token = token }; var response = await RdHttpClient.Instance.PostAsync(_dataUrl + "auth", httpObj.ToJson()); if (response != null) { var commonResponseObj = JsonConvert.DeserializeObject(response); if (commonResponseObj is { code: 200 }) { var authRespStr = JsonConvert.SerializeObject(commonResponseObj.data); var authResp = JsonConvert.DeserializeObject(authRespStr); if (authResp != null) { _session = authResp.session; } } } return response; } public static async Task RefreshMsgList() { var httpObj = new GetMsgObj(_session); var response = await RdHttpClient.Instance.PostAsync(_msgUrl + "api", httpObj.ToJson()); return response; } public static async Task SendMsg(int sendTo, int msgType, string msgContent) { var httpObj = new SendMsgObj(_session, sendTo, msgType, msgContent); var response = await RdHttpClient.Instance.PostAsync(_msgUrl + "epi", httpObj.ToJson()); return response; } public static async Task ConsumeMsg(string msgId) { var httpObj = new ConsumeMsgObj(_session, msgId); var response = await RdHttpClient.Instance.PostAsync(_msgUrl + "api", httpObj.ToJson()); return response; } // ReSharper disable Unity.PerformanceAnalysis public static async Task FindPlayer(int[] findPlayer) { var httpObj = new PlayerOnlineStatusObj(_session, findPlayer); var response = await RdHttpClient.Instance.PostAsync(_msgUrl + "api", httpObj.ToJson()); return response; } public static async Task GetBattleDetailList() { var response = await RdHttpClient.Instance.GetAsync(_msgUrl + "battle?fromPlayer=8&toPlayer=9&fromCock=1&toCock=1"); return response; } } }