_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Login/WebConnact.cs

1272 lines
40 KiB
C#
Raw Normal View History

/*using System;
2024-11-11 19:48:32 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
using Newtonsoft.Json;
2024-11-11 19:48:32 +08:00
public class WebConnact : MonoBehaviour
{
private string token; // <20><><EFBFBD><EFBFBD> token <20>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
void Start()
{
// <20><><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD>¼ע<C2BC><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼<EFBFBD>󷵻ص<F3B7B5BB>token
// <20><><EFBFBD>˵<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ڴ˷<DAB4><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1>
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ص<EFBFBD><D8B5>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>token<65><6E><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> gameEscapeId <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> HandleGameEscapeIdUpdated
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
}
void HandleTokenReceived(string receivedToken)
{
// <20><><EFBFBD><EFBFBD> token
token = receivedToken; // <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD> token <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Debug.Log("HandleTokenReceived<65><64><EFBFBD><EFBFBD>:" + token);
// <20>״ε<D7B4><CEB5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱû<CAB1><C3BB> escapeId <20><><EFBFBD>Դ<EFBFBD><D4B4>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>˴<EFBFBD> -1
Loding(token, -1);
}
void HandleGameEscapeIdUpdated(int newGameEscapeId)
{
Debug.Log("GameEscapeId <20>Ѹ<EFBFBD><D1B8><EFBFBD>Ϊ: " + newGameEscapeId);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Loding <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
Loding(token, newGameEscapeId);
}
// <20><><EFBFBD><EFBFBD> token <20>͸<EFBFBD><CDB8>º<EFBFBD><C2BA><EFBFBD> escapeId
public async void Loding(string token, int newGameEscapeId)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ֵ
string Authorization = token;
Debug.Log("Loding(Authorization)<29><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ֵ: " + Authorization);
// <20><><EFBFBD><EFBFBD> newGameEscapeId <20><><EFBFBD>dz<EFBFBD>ʼֵ<CABC><D6B5>-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>
int escapeId = newGameEscapeId != -1 ? newGameEscapeId : 0;
Debug.Log("ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId: " + escapeId);
// <20><>ʣ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
//<2F><><EFBFBD><EFBFBD><E7A3BA><EFBFBD><EFBFBD>Ҫ<EFBFBD>õ<EFBFBD> escapeId <20>ĵط<C4B5>ֱ<EFBFBD><D6B1>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>
//1.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϣ//<2F><>ͨ<EFBFBD><CDA8>
User_InformationHead user = new User_InformationHead();
Dictionary<string, string> head13 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string UserNewInfoBody = @"
{
""nickName"": ""wulongxiao"",
""headImg"": ""https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png"",
""gender"": 1,
""birthday"": ""2023-12-12 12:12:12""
}";
//<2F><>ӡ JSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
Debug.Log("JSON Request Data: " + UserNewInfoBody);
string response13 = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", UserNewInfoBody, head13);
Debug.Log("1.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϣ" + response13);
//1.4<EFBFBD><EFBFBD>ѯ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string response14 = await web.SendRequest("http://121.40.42.41:8080/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4<EFBFBD><EFBFBD>ѯ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + response14);
//2.1<EFBFBD>̳<EFBFBD><EFBFBD>б<EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Mall_List mall_virtual = new Mall_List();
mall_virtual.productType = 0;
mall_virtual.pageNo = 1;
mall_virtual.pageSize = 20;
string mall_virtualponse = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mall_virtual));
Debug.Log("2.1<EFBFBD>̳<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>" + mall_virtualponse);
//2.1<EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><EFBFBD>б<EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Mall_List mall = new Mall_List();
mall.productType = 1;
//mall.pageNo = 1;
//mall.pageSize = 20;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ʡ<EFBFBD>Բ<EFBFBD>д<EFBFBD><D0B4>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>1<EFBFBD><31>20
string response21 = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mall));
Debug.Log("2.1<EFBFBD>̳<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>" + response21);
//2.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Dictionary<string, string> head22 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
Product_Details product = new Product_Details();
product.productId = 1;
string response22 = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(product), head22);
Debug.Log("JSON Request Data: " + JsonUtility.ToJson(product));
Debug.Log("2.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + response22);
//2.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Mall_buy mall_Buy = new Mall_buy();
Dictionary<string, string> head23 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
mall_Buy.userId = 106;
mall_Buy.productId = 1;
string response23 = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mall_Buy), head23);
Debug.Log("2.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + response23);
//3.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Query_Announcement query_Announcement = new Query_Announcement();
query_Announcement.userId = 106;
query_Announcement.pageNo = 1;
query_Announcement.pageSize = 20;
string response31 = await web.SendRequest("http://121.40.42.41:8080/snail/notice/page", "POST", JsonUtility.ToJson(query_Announcement));
Debug.Log("3.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD>" + response31);
//3.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飺//<2F><>ͨ<EFBFBD><CDA8>
int AnnouncementId = 1;
string response32 = await web.SendRequest($"http://121.40.42.41:8080/snail/notice/info?noticeId={AnnouncementId}", "GET");
Debug.Log("3.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飺" + response32);
//=================================================================================================================================
//4.1<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD>ųط<EFBFBD>ҳ//<2F><>ͨ<EFBFBD><CDA8>
Dictionary<string, string> head41 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
int orderByBeansCoin = 1;
string response41 = await web.SendRequest("http://121.40.42.41:8080/snail/cutePool/page", "POST", JsonUtility.ToJson(orderByBeansCoin), head41);
Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD>ųط<C5B3>ҳ" + response41);
//=================================================================================================================================
//4.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
Dictionary<string, string> head42 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string buyCutePool = @"
{
""userId"": 106,
""cutePoolId"": 2
}";
//<2F><>ӡ JSON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
Debug.Log("JSON Request Data: " + buyCutePool);
string response42 = await web.SendRequest("http://121.40.42.41:8080/snail/cutePool/buy", "POST", buyCutePool, head42);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>" + response42);
//// ============================================================================================================================
//5.1<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ
Dictionary<string, string> head51 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
Debug.Log("5.1<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ: " + response51);
//// ====================================================================================================================
// 5.1.2<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ棩:
Dictionary<string, string> head512 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string queryEscapeRoomListBody = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response512 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", queryEscapeRoomListBody, head512);
Debug.Log("5.1.2<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ棩: " + response512);
//5.1.3<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
Dictionary<string, string> head513 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string userBetBody = $@"
{{
""userId"": 106,
""escapeId"": {escapeId},
""bet"": 100,
""roomNo"":1
}}";
string response513 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", userBetBody, head513);
Debug.Log("5.1.3<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>" + response513);
//5.1.4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ɱ
Dictionary<string, string> head514 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string selectKill = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response514 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", selectKill, head514);
Debug.Log("5.1.4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD>" + response514);
////5.1.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Dictionary<string, string> head515 = new Dictionary<string, string>
{
{ "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
};
string queryUserBetResult = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response515 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", queryUserBetResult, head515);
Debug.Log("5.1.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD>㣺" + response515);
}
void OnDestroy()
{
// ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
}
// Update is called once per frame
void Update()
{
}
}
[Serializable]
public class Search_room//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
{
public int userId;
}
//[Serializable]
//public class loginbody//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//{
// public string userName;
// public string password;
// public int verifyCode;
//}
[System.Serializable]
public class User_InformationHead //<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
{
public string nickName;
public string headImg;
public string gender;
public string birthday;
}
[Serializable]
public class Query_Announcement //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
{
public int userId;
public int pageNo;
public int pageSize;
}
[Serializable]
public class Mall_List //<2F><>ȡ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
{
public int productType;
public int pageNo;
public int pageSize;
}
[Serializable]
public class Product_Details//<2F><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public int productId;
}
[Serializable]
public class Mall_buy
{ public int productId;
public int userId;
}
[Serializable]
public class cutePoolPage {
public int orderByBeansCoin;
}
*/
/*using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class WebConnact : MonoBehaviour
2024-11-11 19:48:32 +08:00
{
private string token; // <20><><EFBFBD><EFBFBD> token <20>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
2024-11-11 19:48:32 +08:00
void Start()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HandleTokenReceived
2024-11-11 19:48:32 +08:00
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> gameEscapeId <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> HandleGameEscapeIdUpdated
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
2024-11-11 19:48:32 +08:00
}
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>
void HandleTokenReceived(string receivedToken)
2024-11-11 19:48:32 +08:00
{
token = receivedToken; // <20><><EFBFBD><EFBFBD> token
// <20>״ε<D7B4><CEB5>ü<EFBFBD><C3BC>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
LoadInitialData(token);
2024-11-11 19:48:32 +08:00
}
// <20><><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>
void HandleGameEscapeIdUpdated(int newGameEscapeId)
{
Debug.Log("GameEscapeId <20>Ѹ<EFBFBD><D1B8><EFBFBD>Ϊ: " + newGameEscapeId);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LoadGameEscapeData(token, newGameEscapeId);
}
2024-11-11 19:48:32 +08:00
// <20><><EFBFBD>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
private async void LoadInitialData(string token)
2024-11-11 19:48:32 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
await UpdateUserInformation(token);
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
await QueryUserDetails(token);
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
await LoadMallData(token);
}
2024-11-11 19:48:32 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async void LoadGameEscapeData(string token, int escapeId)
{
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
await QueryLatestMassacre(token);
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
await QueryEscapeRoomDetails(token, escapeId);
// <20>û<EFBFBD><C3BB><EFBFBD>ע
await UserBet(token, escapeId);
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
await QueryKill(token, escapeId);
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
await QueryUserBetResult(token, escapeId);
}
2024-11-11 19:48:32 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
private async Task UpdateUserInformation(string token)
{
var headers = CreateHeaders(token);
string body = @"
{
""nickName"": ""wulongxiao"",
""headImg"": ""https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png"",
""gender"": 1,
""birthday"": ""2023-12-12 12:12:12""
}";
Debug.Log("<22><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
2024-11-11 19:48:32 +08:00
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
private async Task<string> QueryUserDetails(string token)
{
var headers = CreateHeaders(token);
Debug.Log("<22><><EFBFBD>ڲ<EFBFBD>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/queryUserInfo", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
return response;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
private async Task LoadMallData(string token)
{
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(token, 0);
// <20><>ѯ<EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(token, 1);
// <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
await GetMallProductDetails(token, 1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
await BuyMallProduct(token, 106, 1);
}
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
private async Task QueryMallList(string token, int productType)
{
Mall_List mallList = new Mall_List
{
productType = productType
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mallList));
Debug.Log($"<22>̳<EFBFBD><CCB3>б<EFBFBD> (productType: {productType}) <20><>Ӧ: " + response);
}
// <20><>ȡ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
private async Task GetMallProductDetails(string token, int productId)
{
var headers = CreateHeaders(token);
Product_Details productDetails = new Product_Details
{
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(productDetails), headers);
Debug.Log("<22><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
private async Task BuyMallProduct(string token, int userId, int productId)
{
var headers = CreateHeaders(token);
Mall_buy mallBuy = new Mall_buy
{
userId = userId,
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mallBuy), headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
private async Task QueryLatestMassacre(string token)
{
var headers = CreateHeaders(token);
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async Task QueryEscapeRoomDetails(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20>û<EFBFBD><C3BB><EFBFBD>ע
private async Task UserBet(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId},
""bet"": 100,
""roomNo"": 1
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
Debug.Log("<22>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response);
}
2024-11-11 19:48:32 +08:00
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ
private async Task QueryKill(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
private async Task QueryUserBetResult(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
private Dictionary<string, string> CreateHeaders(string token)
{
return new Dictionary<string, string>
{
{ "Authorization", token }
};
2024-11-11 19:48:32 +08:00
}
2024-11-11 19:48:32 +08:00
void OnDestroy()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
2024-11-11 19:48:32 +08:00
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
2024-11-11 19:48:32 +08:00
}
// Update <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰû<C7B0><C3BB><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>
2024-11-11 19:48:32 +08:00
void Update()
{
}
}*/
/*using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class WebConnact : MonoBehaviour
2024-11-11 19:48:32 +08:00
{
private string token; // <20><><EFBFBD><EFBFBD> token <20>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
private int escapeId = -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId<49><64><EFBFBD><EFBFBD>ʼΪ -1 <20><>ʾδ<CABE><CEB4><EFBFBD><EFBFBD>
void Start()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HandleTokenReceived
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> escapeId <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> HandleGameEscapeIdUpdated
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>
void HandleTokenReceived(string receivedToken)
{
token = receivedToken; // <20><><EFBFBD><EFBFBD> token
// <20>״ε<D7B4><CEB5>ü<EFBFBD><C3BC>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
LoadInitialData(token);
}
// <20><><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>
void HandleGameEscapeIdUpdated(int newGameEscapeId)
{
escapeId = newGameEscapeId; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
Debug.Log("<22><><EFBFBD>յ<EFBFBD><D5B5>µ<EFBFBD> GameEscapeId: " + escapeId);
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵķ<DDB5><C4B7><EFBFBD>
LoadGameEscapeData(token, escapeId);
}
// <20><><EFBFBD>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
private async void LoadInitialData(string token)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
await UpdateUserInformation(token);
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
await QueryUserDetails(token);
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
await LoadMallData(token);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async void LoadGameEscapeData(string token, int escapeId)
{
if (escapeId == -1)
{
Debug.LogWarning("<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>escapeId δ<><CEB4><EFBFBD>á<EFBFBD>");
return;
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
await QueryLatestMassacre(token);
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
await QueryEscapeRoomDetails(token, escapeId);
// <20>û<EFBFBD><C3BB><EFBFBD>ע
await UserBet(token, escapeId);
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
await QueryKill(token, escapeId);
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
await QueryUserBetResult(token, escapeId);
}
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
private async Task UpdateUserInformation(string token)
{
var headers = CreateHeaders(token);
string body = @"
{
""nickName"": ""wulongxiao"",
""headImg"": ""https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png"",
""gender"": 1,
""birthday"": ""2023-12-12 12:12:12""
}";
Debug.Log("<22><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
private async Task<string> QueryUserDetails(string token)
{
var headers = CreateHeaders(token);
Debug.Log("<22><><EFBFBD>ڲ<EFBFBD>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/queryUserInfo", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
return response;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
private async Task LoadMallData(string token)
{
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(token, 0);
// <20><>ѯ<EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(token, 1);
// <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
await GetMallProductDetails(token, 1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
await BuyMallProduct(token, 106, 1);
}
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
private async Task QueryMallList(string token, int productType)
{
Mall_List mallList = new Mall_List
{
productType = productType
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mallList));
Debug.Log($"<22>̳<EFBFBD><CCB3>б<EFBFBD> (productType: {productType}) <20><>Ӧ: " + response);
}
// <20><>ȡ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
private async Task GetMallProductDetails(string token, int productId)
{
var headers = CreateHeaders(token);
Product_Details productDetails = new Product_Details
{
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(productDetails), headers);
Debug.Log("<22><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
private async Task BuyMallProduct(string token, int userId, int productId)
{
var headers = CreateHeaders(token);
Mall_buy mallBuy = new Mall_buy
{
userId = userId,
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mallBuy), headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
private async Task QueryLatestMassacre(string token)
{
var headers = CreateHeaders(token);
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async Task QueryEscapeRoomDetails(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20>û<EFBFBD><C3BB><EFBFBD>ע
private async Task UserBet(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId},
""bet"": 100,
""roomNo"": 1
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
Debug.Log("<22>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ
private async Task QueryKill(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
private async Task QueryUserBetResult(string token, int escapeId)
{
var headers = CreateHeaders(token);
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
private Dictionary<string, string> CreateHeaders(string token)
{
return new Dictionary<string, string>
{
{ "Authorization", token }
};
}
void OnDestroy()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
}
}*/
/*using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class WebConnact : MonoBehaviour
{
private string token; // <20><><EFBFBD><EFBFBD> token <20>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
private int escapeId = -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId<49><64><EFBFBD><EFBFBD>ʼΪ -1 <20><>ʾδ<CABE><CEB4><EFBFBD><EFBFBD>
void Start()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HandleTokenReceived
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> escapeId <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> HandleGameEscapeIdUpdated<65><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>
void HandleTokenReceived(string receivedToken)
{
token = receivedToken; // <20><><EFBFBD><EFBFBD> token
// <20>״ε<D7B4><CEB5>ü<EFBFBD><C3BC>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
LoadInitialData();
}
// <20><><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
void HandleGameEscapeIdUpdated(int newGameEscapeId)
{
escapeId = newGameEscapeId; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
Debug.Log("<22><><EFBFBD>յ<EFBFBD><D5B5>µ<EFBFBD> GameEscapeId: " + escapeId);
}
// <20><><EFBFBD>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
private async void LoadInitialData()
{
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
await UpdateUserInformation();
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
await QueryUserDetails();
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
await LoadMallData();
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
public async void LoadGameEscapeData()
{
if (escapeId == -1)
{
Debug.LogWarning("<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>escapeId δ<><CEB4><EFBFBD>á<EFBFBD>");
return;
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
//await QueryLatestMassacre();
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
await QueryEscapeRoomDetails();
// <20>û<EFBFBD><C3BB><EFBFBD>ע
await UserBet();
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
await QueryKill();
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
await QueryUserBetResult();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
private async Task UpdateUserInformation()
{
var headers = CreateHeaders();
string body = @"
{
""nickName"": ""wulongxiao"",
""headImg"": ""https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png"",
""gender"": 1,
""birthday"": ""2023-12-12 12:12:12""
}";
Debug.Log("<22><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
private async Task<string> QueryUserDetails()
{
var headers = CreateHeaders();
Debug.Log("<22><><EFBFBD>ڲ<EFBFBD>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/queryUserInfo", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
return response;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
private async Task LoadMallData()
{
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(0);
// <20><>ѯ<EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(1);
// <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
await GetMallProductDetails(1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
await BuyMallProduct(106, 1);
}
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
private async Task QueryMallList(int productType)
{
Mall_List mallList = new Mall_List
{
productType = productType
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mallList));
Debug.Log($"<22>̳<EFBFBD><CCB3>б<EFBFBD> (productType: {productType}) <20><>Ӧ: " + response);
}
// <20><>ȡ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
private async Task GetMallProductDetails(int productId)
{
var headers = CreateHeaders();
Product_Details productDetails = new Product_Details
{
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(productDetails), headers);
Debug.Log("<22><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
private async Task BuyMallProduct(int userId, int productId)
{
var headers = CreateHeaders();
Mall_buy mallBuy = new Mall_buy
{
userId = userId,
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mallBuy), headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>Ӧ: " + response);
}
//// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
//private async Task QueryLatestMassacre()
//{
// var headers = CreateHeaders();
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
// Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1>Ӧ: " + response);
//}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async Task QueryEscapeRoomDetails()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20>û<EFBFBD><C3BB><EFBFBD>ע
private async Task UserBet()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId},
""bet"": 100,
""roomNo"": 1
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
Debug.Log("<22>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ
private async Task QueryKill()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
private async Task QueryUserBetResult()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
private Dictionary<string, string> CreateHeaders()
{
return new Dictionary<string, string>
{
{ "Authorization", token }
};
}
void OnDestroy()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
}
}*/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class WebConnact : MonoBehaviour
{
2024-11-12 19:59:15 +08:00
public string token = null; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token<65><6E><EFBFBD><EFBFBD>ʼΪ null
public int escapeId = -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId<49><64><EFBFBD><EFBFBD>ʼΪ -1 <20><>ʾδ<CABE><CEB4><EFBFBD><EFBFBD>
void Start()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HandleTokenReceived
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> escapeId <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> HandleGameEscapeIdUpdated<65><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
selectGameEscape512.OnGameEscapeIdUpdated += HandleGameEscapeIdUpdated;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> token ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> token
2024-11-12 19:59:15 +08:00
public void HandleTokenReceived(string receivedToken)
{
token = receivedToken; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
2024-11-12 19:59:15 +08:00
// <20>״ε<D7B4><CEB5>ü<EFBFBD><C3BC>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
//LoadInitialData();
//LoadGameEscapeData();
Debug.Log("<22><><EFBFBD>յ<EFBFBD><D5B5>µ<EFBFBD> token: " + token);
}
// <20><><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
2024-11-12 19:59:15 +08:00
public void HandleGameEscapeIdUpdated(int newGameEscapeId)
{
escapeId = newGameEscapeId; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId
2024-11-12 19:59:15 +08:00
//LoadGameEscapeData();
//Debug.Log("<22><><EFBFBD>յ<EFBFBD><D5B5>µ<EFBFBD> GameEscapeId: " + escapeId);
}
// <20><><EFBFBD>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ݣ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
public async void LoadInitialData()
{
if (string.IsNullOrEmpty(token))
{
Debug.LogWarning("<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD>س<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ݣ<EFBFBD>token δ<><CEB4><EFBFBD>á<EFBFBD>");
return;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
await UpdateUserInformation();
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
await QueryUserDetails();
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
await LoadMallData();
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> escapeId <20><> token
public async void LoadGameEscapeData()
{
if (string.IsNullOrEmpty(token))
{
Debug.LogWarning("<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>token δ<><CEB4><EFBFBD>á<EFBFBD>");
return;
}
if (escapeId == -1)
{
Debug.LogWarning("<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>escapeId δ<><CEB4><EFBFBD>á<EFBFBD>");
return;
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
2024-11-12 19:59:15 +08:00
// await QueryLatestMassacre();
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
await QueryEscapeRoomDetails();
// <20>û<EFBFBD><C3BB><EFBFBD>ע
await UserBet();
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
await QueryKill();
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
await QueryUserBetResult();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
2024-11-12 19:59:15 +08:00
public async Task UpdateUserInformation()
{
var headers = CreateHeaders();
string body = @"
{
""nickName"": ""wulongxiao"",
""headImg"": ""https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png"",
""gender"": 1,
""birthday"": ""2023-12-12 12:12:12""
}";
Debug.Log("<22><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task<string> QueryUserDetails()
{
var headers = CreateHeaders();
Debug.Log("<22><><EFBFBD>ڲ<EFBFBD>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ...");
string response = await web.SendRequest("http://121.40.42.41:8080/snail/user/queryUserInfo", "POST", "{}", headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
return response;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task LoadMallData()
{
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(0);
// <20><>ѯ<EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
await QueryMallList(1);
// <20><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
await GetMallProductDetails(1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
await BuyMallProduct(106, 1);
}
// <20><>ѯ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task QueryMallList(int productType)
{
var headers = CreateHeaders();
Mall_List mallList = new Mall_List
{
productType = productType
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mallList), headers);
Debug.Log($"<22>̳<EFBFBD><CCB3>б<EFBFBD> (productType: {productType}) <20><>Ӧ: " + response);
}
// <20><>ȡ<EFBFBD>̳<EFBFBD><CCB3><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task GetMallProductDetails(int productId)
{
var headers = CreateHeaders();
Product_Details productDetails = new Product_Details
{
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(productDetails), headers);
Debug.Log("<22><>ȡ<EFBFBD><C8A1>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
2024-11-12 19:59:15 +08:00
public async Task BuyMallProduct(int userId, int productId)
{
var headers = CreateHeaders();
Mall_buy mallBuy = new Mall_buy
{
userId = userId,
productId = productId
};
string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mallBuy), headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>Ӧ: " + response);
}
2024-11-12 19:59:15 +08:00
//// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ɱ
//public async Task QueryLatestMassacre()
//{
// var headers = CreateHeaders();
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", headers);
// Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1>Ӧ: " + response);
//}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task QueryEscapeRoomDetails()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryEscapeRoomList", "POST", body, headers);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
// <20>û<EFBFBD><C3BB><EFBFBD>ע
2024-11-12 19:59:15 +08:00
public async Task UserBet()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId},
""bet"": 100,
""roomNo"": 1
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/userBet", "POST", body, headers);
Debug.Log("<22>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ
2024-11-12 19:59:15 +08:00
public async Task QueryKill()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryKill", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD><D1AF>ɱ<EFBFBD><C9B1>Ϣ<EFBFBD><CFA2>Ӧ: " + response);
}
// <20><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
2024-11-12 19:59:15 +08:00
public async Task QueryUserBetResult()
{
var headers = CreateHeaders();
string body = $@"
{{
""userId"": 106,
""escapeId"": {escapeId}
}}";
string response = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryUserBetResult", "POST", body, headers);
Debug.Log("<22><>ѯ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
}
2024-11-11 19:48:32 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
2024-11-12 19:59:15 +08:00
public Dictionary<string, string> CreateHeaders()
{
if (string.IsNullOrEmpty(token))
{
Debug.LogWarning("<22><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷʱ<CDB7><CAB1>token δ<><CEB4><EFBFBD>á<EFBFBD>");
return new Dictionary<string, string>();
}
2024-11-11 19:48:32 +08:00
return new Dictionary<string, string>
{
{ "Authorization", token }
};
}
void OnDestroy()
{
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
selectGameEscape512.OnGameEscapeIdUpdated -= HandleGameEscapeIdUpdated;
}
2024-11-11 19:48:32 +08:00
}
//[Serializable]
//public class loginbody//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//{
// public string userName;
// public string password;
// public int verifyCode;
//}
[System.Serializable]
public class User_InformationHead //<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
{
public string nickName;
public string headImg;
public string gender;
public string birthday;
}
[Serializable]
public class Query_Announcement //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
{
public int userId;
public int pageNo;
public int pageSize;
}
[Serializable]
public class Mall_List //<2F><>ȡ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
{
public int productType;
public int pageNo;
public int pageSize;
2024-11-11 19:48:32 +08:00
}
[Serializable]
public class Product_Details//<2F><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public int productId;
2024-11-11 19:48:32 +08:00
}
[Serializable]
public class Mall_buy
{
public int productId;
2024-11-11 19:48:32 +08:00
public int userId;
}
[Serializable]
public class cutePoolPage
{
public int orderByBeansCoin;
}