123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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<string> 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<CommonResponseObj>(response);
- if (commonResponseObj is { code: 200 })
- {
- var authRespStr = JsonConvert.SerializeObject(commonResponseObj.data);
- var authResp = JsonConvert.DeserializeObject<AuthResponseObj>(authRespStr);
- if (authResp != null)
- {
- _session = authResp.session;
- }
- }
- }
- return response;
- }
- public static async Task<string> RefreshMsgList()
- {
- var httpObj = new GetMsgObj(_session);
- var response = await RdHttpClient.Instance.PostAsync(_msgUrl + "api", httpObj.ToJson());
- return response;
- }
- public static async Task<string> 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<string> 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<string> 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<string> GetBattleDetailList()
- {
- var response =
- await RdHttpClient.Instance.GetAsync(_msgUrl + "battle?fromPlayer=8&toPlayer=9&fromCock=1&toCock=1");
- return response;
- }
- }
- }
|