NetWorkHeaders.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Security.Cryptography;
  5. using XRTool.Util;
  6. using LitJson;
  7. using System;
  8. using System.Text;
  9. using UnityEngine.Networking;
  10. using System.Linq;
  11. public class NetWorkHeaders : MonoBehaviour
  12. {
  13. private List<Network> queue;
  14. private static bool init;
  15. public static NetWorkHeaders Instance;
  16. public static string MD5STR = "sTuDi0jH7FlCgd";
  17. void Awake()
  18. {
  19. if (!init)
  20. {
  21. init = true;
  22. Instance = this;
  23. queue = new List<Network>();
  24. DontDestroyOnLoad(this.gameObject);
  25. }
  26. else
  27. {
  28. Destroy(this.gameObject);
  29. return;
  30. }
  31. }
  32. /// <summary>
  33. /// Adds the network.
  34. /// </summary>
  35. /// <param name="action">Action.</param>
  36. /// <param name="data">Data.</param>
  37. /// <param name="type">Type.</param>
  38. /// <param name="successFun">Success fun.</param>
  39. /// <param name="failedFun">Failed fun.</param>
  40. public void AddNetwork(string action, JsonData data, Action<JsonData> successFun = null, Action<string> failedFun = null)
  41. {
  42. Network net = new Network();
  43. net.init(action, data, successFun, failedFun);
  44. queue.Add(net);
  45. checkQueue();
  46. }
  47. void checkQueue()
  48. {
  49. UnityLog.Log("networkQueueCount: " + queue.Count);
  50. if (queue.Count == 0)
  51. {
  52. return;
  53. }
  54. if (queue[0].active)
  55. {
  56. return;
  57. }
  58. StartCoroutine(post(queue[0]));
  59. }
  60. IEnumerator post(Network net)
  61. {
  62. CommonMethod.ShowNetLoading("NetWork","通讯中...");
  63. net.active = true;
  64. string url = net.action;
  65. JsonData form = net.data;
  66. byte[] postBytes = System.Text.Encoding.Default.GetBytes(form.ToJson());
  67. //UnityLog.Log("token===>" + UserInfo.Token);
  68. UnityWebRequest www = new UnityWebRequest(url, "POST");
  69. www.uploadHandler = (UploadHandler)new UploadHandlerRaw(postBytes);
  70. www.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
  71. // www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  72. www.SetRequestHeader("Content-Type", "application/json");
  73. www.SetRequestHeader("unionId", UserInfo.UnionId);
  74. www.SetRequestHeader("token", UserInfo.User_Token);
  75. // www.uploadHandler =new UploadHandlerRaw(body);
  76. // WWW www = new WWW(url, form);
  77. UnityLog.Log("url: " + www.url);
  78. UnityLog.Log("param: " + net.data.ToJson());
  79. yield return www.SendWebRequest();//等待Web服务器的反应
  80. CommonMethod.HideNetLoading("NetWork");
  81. string result = string.Empty;
  82. if (www.error != null)
  83. {
  84. result = www.error;
  85. Debug.Log("networkError: " + result);
  86. postError("1009");
  87. }
  88. else if(www.isDone)
  89. {
  90. result = www.downloadHandler.text;
  91. UnityLog.Log("networkSuccess: " + result);
  92. postSuccess(result);
  93. }
  94. queue.RemoveAt(0);
  95. checkQueue();
  96. }
  97. void postSuccess(string postData)
  98. {
  99. JsonData data = null;
  100. string code = "";
  101. Debug.Log(postData);
  102. try
  103. {
  104. data = JsonMapper.ToObject(postData);
  105. code = data["code"].ToString();
  106. }
  107. catch (Exception e)
  108. {
  109. Debug.Log(e.Data);
  110. postError("1009");
  111. }
  112. switch (code)
  113. {
  114. case "200":
  115. queue[0].scuess(data);
  116. break;
  117. default:
  118. UnityLog.Log("error");
  119. //if (data["message"].ToString() == "vaild account")
  120. //{
  121. // //PlayerPrefs.SetString(UserInfo.Account, "");
  122. //}
  123. queue[0].failed(postData);
  124. break;
  125. }
  126. }
  127. void postError(string errorData)
  128. {
  129. queue[0].error(errorData);
  130. }
  131. public void getNetTexture(string action, WWWForm data, Action<Texture> success = null)
  132. {
  133. StartCoroutine(LoadTextureFromLocal(action, data, success));
  134. }
  135. //读取纹理
  136. IEnumerator LoadTextureFromLocal(string action, WWWForm data = null, Action<Texture> success = null)
  137. {
  138. //UnityLog.Log("tupian123................" + action);
  139. WWW w;
  140. if (data != null)
  141. w = new WWW(action, data);
  142. else
  143. w = new WWW(action);
  144. yield return w;
  145. if (w.isDone)
  146. {
  147. // Material material = new Material(Shader.Find("Unlit/Texture"));
  148. //UnityLog.Log("tupian321................");
  149. // material.mainTexture = w.texture;
  150. if (success != null)
  151. success(w.texture);
  152. }
  153. }
  154. /// <summary>
  155. /// MD5码
  156. /// </summary>
  157. /// <param name="strText"></param>
  158. /// <returns></returns>
  159. public static string MD5Encrypt(string strText)
  160. {
  161. MD5 md5 = MD5.Create();
  162. byte[] fromData = Encoding.Default.GetBytes(strText);
  163. byte[] targetData = md5.ComputeHash(fromData);
  164. StringBuilder byte2String = new StringBuilder();
  165. for (int i = 0; i < targetData.Length; i++)
  166. {
  167. byte2String.AppendFormat("{0:x2}", targetData[i]);
  168. }
  169. return byte2String.ToString();
  170. }
  171. public static string FieldToString(JsonData data)
  172. {
  173. Dictionary<string, string> dic = new Dictionary<string, string>();
  174. foreach (string key in data.Keys)
  175. {
  176. dic.Add(key, data[key].ToString());
  177. }
  178. string str = "";
  179. int count = 0;
  180. Dictionary<string, string> dicDesc = dic.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
  181. foreach (string kvp in dicDesc.Keys)
  182. {
  183. count++;
  184. if (data.Keys.Count <= count)
  185. {
  186. str = str + kvp + "=" + data[kvp];
  187. }
  188. else
  189. {
  190. str = str + kvp + "=" + data[kvp] + "&";
  191. }
  192. }
  193. return str + MD5STR;
  194. }
  195. public static void SendHttp(JsonData jsonData, Action<JsonData> success = null, Action<string> failed = null)
  196. {
  197. Dictionary<string, string> data = new Dictionary<string, string>();
  198. foreach (string key in jsonData.Keys)
  199. {
  200. data.Add(key, jsonData[key].ToString());
  201. }
  202. #if BUILDTYPE_RELEASE || BUILDTYPE_TEST
  203. data.Add("sign", "588cd263bfd7a7b5e561dba46b989ef1");
  204. //string md5 = MD5Encrypt(MD5Encrypt(FieldToString(jsonData)));
  205. //Debug.Log(md5);
  206. //data.AddField("sign", md5);
  207. #endif
  208. #if BUILDTYPE_DEBUG
  209. // data.AddField("sign", "588cd263bfd7a7b5e561dba46b989ef1");
  210. string md5 = MD5Encrypt(MD5Encrypt(FieldToString(jsonData)));
  211. Debug.Log(md5);
  212. data.Add("sign", md5);
  213. #endif
  214. string action = NetWorkHeadersConfig.Remote_Net_url+ jsonData["action"].ToString();
  215. NetWorkHeaders.Instance.AddNetwork(action, jsonData, success, failed);
  216. }
  217. /// <summary>
  218. /// 账号密码登录
  219. /// </summary>
  220. /// <param name="account"></param>
  221. /// <param name="password"></param>
  222. /// <param name="success"></param>
  223. /// <param name="failed"></param>
  224. public static void Login(string account, string password, Action<JsonData> success = null, Action<string> failed = null)
  225. {
  226. JsonData jsdata = new JsonData();
  227. jsdata["action"] = "/account/login";
  228. jsdata["account"] = account;
  229. jsdata["deviceid"] = DeviceInfo.SN;
  230. jsdata["devicetype"] = DeviceInfo.MODEL;
  231. jsdata["deviceos"] = DeviceInfo.RELEASE_VERSION;
  232. jsdata["password"] = password;
  233. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  234. UnityLog.Log(jsdata.ToJson());
  235. SendHttp(jsdata, success, failed);
  236. }
  237. /// <summary>
  238. /// 预登陆
  239. /// </summary>
  240. /// <param name="account"></param>
  241. /// <param name="password"></param>
  242. /// <param name="success"></param>
  243. /// <param name="failed"></param>
  244. public static void YuLogin(string account, string password, Action<JsonData> success = null, Action<string> failed = null)
  245. {
  246. JsonData jsdata = new JsonData();
  247. jsdata["action"] = "/account/advance";
  248. jsdata["account"] = account;
  249. jsdata["password"] = password;
  250. UnityLog.Log(jsdata.ToJson());
  251. SendHttp(jsdata, success, failed);
  252. }
  253. /// <summary>
  254. /// 预登陆,需要验证码
  255. /// </summary>
  256. /// <param name="account"></param>
  257. /// <param name="password"></param>
  258. /// <param name="success"></param>
  259. /// <param name="failed"></param>
  260. public static void YuLogin(string account, string password, string captcha, string captchaId, Action<JsonData> success = null, Action<string> failed = null)
  261. {
  262. JsonData jsdata = new JsonData();
  263. jsdata["action"] = "/account/advance";
  264. jsdata["Account"] = account;
  265. jsdata["captcha"] = captcha;
  266. jsdata["captchaId"] = captchaId;
  267. jsdata["password"] = password;
  268. UnityLog.Log(jsdata.ToJson());
  269. SendHttp(jsdata, success, failed);
  270. }
  271. /// <summary>
  272. /// 账号密码登录,需要验证码
  273. /// </summary>
  274. /// <param name="account"></param>
  275. /// <param name="password"></param>
  276. /// <param name="success"></param>
  277. /// <param name="failed"></param>
  278. public static void GetUserInfo(Action<JsonData> success = null, Action<string> failed = null)
  279. {
  280. JsonData jsdata = new JsonData();
  281. jsdata["action"] = "/user/userInfo";
  282. UnityLog.Log(jsdata.ToJson());
  283. SendHttp(jsdata, success, failed);
  284. }
  285. public static void Activate(string license, Action<JsonData> success = null, Action<string> failed = null)
  286. {
  287. JsonData jsdata = new JsonData();
  288. jsdata["action"] = "/account/activate";
  289. jsdata["unionId"] = UserInfo.UnionId;
  290. jsdata["token"] = UserInfo.User_Token;
  291. jsdata["license"] = license;
  292. UnityLog.Log(jsdata.ToJson());
  293. SendHttp(jsdata, success, failed);
  294. }
  295. /// <summary>
  296. /// 账号密码登录,需要验证码
  297. /// </summary>
  298. /// <param name="account"></param>
  299. /// <param name="password"></param>
  300. /// <param name="success"></param>
  301. /// <param name="failed"></param>
  302. public static void SetUserInfo(Action<JsonData> success = null, Action<string> failed = null)
  303. {
  304. JsonData jsdata = new JsonData();
  305. jsdata["action"] = "/user/profile";
  306. jsdata["nickName"] = UserInfo.userName;
  307. jsdata["avatar"] = UserInfo.avatar;
  308. UnityLog.Log(jsdata.ToJson());
  309. SendHttp(jsdata, success, failed);
  310. }
  311. /// <summary>
  312. /// 账号密码登录,需要验证码
  313. /// </summary>
  314. /// <param name="account"></param>
  315. /// <param name="password"></param>
  316. /// <param name="success"></param>
  317. /// <param name="failed"></param>
  318. public static void GetUserAvater(Action<JsonData> success = null, Action<string> failed = null)
  319. {
  320. JsonData jsdata = new JsonData();
  321. jsdata["action"] = "/common/avatar";
  322. UnityLog.Log(jsdata.ToJson());
  323. SendHttp(jsdata, success, failed);
  324. }
  325. /// <summary>
  326. /// 账号密码登录,需要验证码
  327. /// </summary>
  328. /// <param name="account"></param>
  329. /// <param name="password"></param>
  330. /// <param name="success"></param>
  331. /// <param name="failed"></param>
  332. public static void SetUserSys(bool mic,bool camera,int resolution, Action<JsonData> success = null, Action<string> failed = null)
  333. {
  334. JsonData jsdata = new JsonData();
  335. jsdata["action"] = "/settings/modify";
  336. jsdata["mic"] = mic;
  337. jsdata["camera"] = camera;
  338. jsdata["resolution"] = resolution;
  339. UnityLog.Log(jsdata.ToJson());
  340. SendHttp(jsdata, success, failed);
  341. }
  342. /// <summary>
  343. /// 发送验证码
  344. /// </summary>
  345. /// <param name="phone"></param>
  346. /// <param name="success"></param>
  347. /// <param name="failed"></param>
  348. public static void SendVerifycode(string phone, Action<JsonData> success = null, Action<string> failed = null)
  349. {
  350. JsonData jsdata = new JsonData();
  351. jsdata["action"] = "/account/sms";
  352. jsdata["phone"] = phone;
  353. UnityLog.Log(jsdata.ToJson());
  354. SendHttp(jsdata, success, failed);
  355. }
  356. /// <summary>
  357. /// 手机验证登录
  358. /// </summary>
  359. /// <param name="phone"></param>
  360. /// <param name="code"></param>
  361. /// <param name="success"></param>
  362. /// <param name="failed"></param>
  363. public static void PhoneLogin(string phone, string code, Action<JsonData> success = null, Action<string> failed = null)
  364. {
  365. JsonData jsdata = new JsonData();
  366. jsdata["action"] = "/account/phoneLogin";
  367. jsdata["phone"] = phone;
  368. jsdata["code"] = code;
  369. UnityLog.Log(jsdata.ToJson());
  370. SendHttp(jsdata, success, failed);
  371. }
  372. public static void YuPhoneLogin(string phone, Action<JsonData> success = null, Action<string> failed = null)
  373. {
  374. JsonData jsdata = new JsonData();
  375. jsdata["action"] = "/account/phoneAdvance";
  376. jsdata["phone"] = phone;
  377. UnityLog.Log(jsdata.ToJson());
  378. SendHttp(jsdata, success, failed);
  379. }
  380. public static void GetOtherModel(string art_type, Action<JsonData> success = null, Action<string> failed = null)
  381. {
  382. JsonData jsdata = new JsonData();
  383. jsdata["action"] = "20504";
  384. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  385. jsdata["user_token"] = UserInfo.User_Token;
  386. jsdata["art_type"] = art_type;
  387. SendHttp(jsdata, success, failed);
  388. }
  389. public static void GetUrlmodel( Action<JsonData> success = null, Action<string> failed = null)
  390. {
  391. JsonData jsdata = new JsonData();
  392. jsdata["action"] = "10102";
  393. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  394. jsdata["user_token"] = UserInfo.User_Token;
  395. SendHttp(jsdata, success, failed);
  396. }
  397. /// <summary>
  398. /// SN登录
  399. /// </summary>
  400. /// <param name="success"></param>
  401. /// <param name="failed"></param>
  402. public static void SNLogin(Action<JsonData> success = null, Action<string> failed = null)
  403. {
  404. JsonData jsdata = new JsonData();
  405. jsdata["action"] = "/account/snLogin";
  406. #if BUILDTYPE_RELEASE || BUILDTYPE_TEST
  407. jsdata["sn"] = DeviceInfo.SN;
  408. #endif
  409. #if BUILDTYPE_DEBUG
  410. #endif
  411. jsdata["sn"] = DeviceInfo.SN;
  412. //jsdata["sn"] = "YARA011805080998";
  413. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  414. SendHttp(jsdata, success, failed);
  415. }
  416. /// <summary>
  417. /// 获取头像列表
  418. /// </summary>
  419. /// <param name="success"></param>
  420. /// <param name="failed"></param>
  421. public static void GetAvatarList(Action<JsonData> success = null, Action<string> failed = null)
  422. {
  423. JsonData jsdata = new JsonData();
  424. jsdata["action"] = "10005";
  425. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  426. SendHttp(jsdata, success, failed);
  427. }
  428. /// <summary>
  429. /// 顶号登陆
  430. /// </summary>
  431. /// <param name="success"></param>
  432. /// <param name="failed"></param>
  433. public static void BreakNumLogin(Action<JsonData> success = null, Action<string> failed = null)
  434. {
  435. JsonData jsdata = new JsonData();
  436. jsdata["action"] = "10006";
  437. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  438. jsdata["user_token"] = CommonMethod.tempToken;
  439. SendHttp(jsdata, success, failed);
  440. }
  441. /// <summary>
  442. /// 获取图形验证码
  443. /// </summary>
  444. /// <param name="success"></param>
  445. /// <param name="failed"></param>
  446. public static void GetTextureCode(Action<JsonData> success = null, Action<string> failed = null)
  447. {
  448. JsonData jsonData = new JsonData();
  449. jsonData["action"] = "/account/captcha";
  450. jsonData["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  451. // NetWorkHeaders.Instance.getNetTexture(action, data, success);
  452. // NetWorkHeaders.Instance.AddNetwork(action, data, success, failed);
  453. SendHttp(jsonData, success, failed);
  454. }
  455. /// <summary>
  456. /// 修改用户信息
  457. /// </summary>
  458. /// <param name="avatar"></param>
  459. /// <param name="nick_name"></param>
  460. /// <param name="success"></param>
  461. /// <param name="failed"></param>
  462. public static void ChangeUserInfo(string avatar = null, string nick_name = null, Action<JsonData> success = null, Action<string> failed = null)
  463. {
  464. JsonData jsdata = new JsonData();
  465. jsdata["action"] = "20000";
  466. jsdata["avatar"] = avatar;
  467. jsdata["nick_name"] = nick_name;
  468. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  469. jsdata["user_token"] = UserInfo.User_Token;
  470. SendHttp(jsdata, success, failed);
  471. }
  472. /// <summary>
  473. /// 获取个人房间列表
  474. /// </summary>
  475. /// <param name="success"></param>
  476. /// <param name="failed"></param>
  477. public static void GetPrivateRoomList(Action<JsonData> success = null, Action<string> failed = null)
  478. {
  479. JsonData jsdata = new JsonData();
  480. jsdata["action"] = "20202";
  481. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  482. jsdata["user_token"] = UserInfo.User_Token;
  483. SendHttp(jsdata, success, failed);
  484. }
  485. /// <summary>
  486. /// 创建个人房间
  487. /// </summary>
  488. /// <param name="room_name"></param>
  489. /// <param name="room_explain"></param>
  490. /// <param name="success"></param>
  491. /// <param name="failed"></param>
  492. public static void CreatePrivateRoom(string room_name, string room_explain = null, Action<JsonData> success = null, Action<string> failed = null)
  493. {
  494. JsonData jsdata = new JsonData();
  495. jsdata["action"] = "20201";
  496. jsdata["room_name"] = room_name;
  497. jsdata["room_explain"] = room_explain;
  498. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  499. jsdata["user_token"] = UserInfo.User_Token;
  500. SendHttp(jsdata, success, failed);
  501. }
  502. /// <summary>
  503. /// 创建公开房间
  504. /// </summary>
  505. /// <param name="room_name"></param>
  506. /// <param name="max_member"></param>
  507. /// <param name="room_type">公开房间类型 1.公开浏览 2.公开交互</param>
  508. /// <param name="room_explain"></param>
  509. /// <param name="room_password"></param>
  510. /// <param name="success"></param>
  511. /// <param name="failed"></param>
  512. public static void CreatePublicRoom(string room_name, string max_member, string room_type, string room_password = null, string room_explain = null,Action<JsonData> success = null, Action<string> failed = null)
  513. {
  514. JsonData jsdata = new JsonData();
  515. jsdata["action"] = "20200";
  516. jsdata["max_member"] = max_member;
  517. jsdata["room_name"] = room_name;
  518. jsdata["room_explain"] = room_explain;
  519. jsdata["room_password"] = room_password;
  520. jsdata["room_type"] = room_type;
  521. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  522. jsdata["user_token"] = UserInfo.User_Token;
  523. SendHttp(jsdata, success, failed);
  524. }
  525. /// <summary>
  526. /// 删除房间
  527. /// </summary>
  528. /// <param name="room_id"></param>
  529. /// <param name="success"></param>
  530. /// <param name="failed"></param>
  531. public static void DeleteRoom(string room_id, Action<JsonData> success = null, Action<string> failed = null)
  532. {
  533. JsonData jsdata = new JsonData();
  534. jsdata["action"] = "20203";
  535. jsdata["room_id"] = room_id;
  536. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  537. jsdata["user_token"] = UserInfo.User_Token;
  538. SendHttp(jsdata, success, failed);
  539. }
  540. /// <summary>
  541. /// 获取设置列表
  542. /// </summary>
  543. /// <param name="success"></param>
  544. /// <param name="failed"></param>
  545. public static void GetSettingList(Action<JsonData> success = null, Action<string> failed = null)
  546. {
  547. JsonData jsdata = new JsonData();
  548. jsdata["action"] = "10100";
  549. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  550. SendHttp(jsdata, success, failed);
  551. }
  552. /// <summary>
  553. /// 获取我的设置
  554. /// </summary>
  555. /// <param name="success"></param>
  556. /// <param name="failed"></param>
  557. public static void GetMySettings(Action<JsonData> success = null, Action<string> failed = null)
  558. {
  559. JsonData jsdata = new JsonData();
  560. jsdata["action"] = "20100";
  561. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  562. jsdata["user_token"] = UserInfo.User_Token;
  563. SendHttp(jsdata, success, failed);
  564. }
  565. /// <summary>
  566. /// 修改我的设置
  567. /// </summary>
  568. /// <param name="camera"></param>
  569. /// <param name="mic"></param>
  570. /// <param name="ratio"></param>
  571. /// <param name="fps"></param>
  572. /// <param name="success"></param>
  573. /// <param name="failed"></param>
  574. public static void ChangeMySettings(string camera = null, string mic = null, string ratio = null, string fps = null, Action<JsonData> success = null, Action<string> failed = null)
  575. {
  576. JsonData jsdata = new JsonData();
  577. jsdata["action"] = "20101";
  578. jsdata["camera"] = camera;
  579. jsdata["fps"] = fps;
  580. jsdata["mic"] = mic;
  581. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  582. jsdata["ratio"] = ratio;
  583. jsdata["user_token"] = UserInfo.User_Token;
  584. SendHttp(jsdata, success, failed);
  585. }
  586. /// <summary>
  587. /// 获取房间模型列表
  588. /// </summary>
  589. /// <param name="room_id"></param>
  590. /// <param name="success"></param>
  591. /// <param name="failed"></param>
  592. public static void GetRoomModelList(string room_id, Action<JsonData> success = null, Action<string> failed = null)
  593. {
  594. JsonData jsdata = new JsonData();
  595. jsdata["action"] = "20204";
  596. jsdata["room_id"] = room_id;
  597. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  598. jsdata["user_token"] = UserInfo.User_Token;
  599. SendHttp(jsdata, success, failed);
  600. }
  601. /// <summary>
  602. /// 创建模型
  603. /// </summary>
  604. /// <param name="art_id"></param>
  605. /// <param name="model_name"></param>
  606. /// <param name="model_info"></param>
  607. /// <param name="room_id"></param>
  608. /// <param name="model_extended"></param>
  609. /// <param name="success"></param>
  610. /// <param name="failed"></param>
  611. public static void CreateModel(string art_id, string model_name, string model_info, string room_id, string model_extended = null, Action<JsonData> success = null, Action<string> failed = null)
  612. {
  613. JsonData jsdata = new JsonData();
  614. jsdata["action"] = "20300";
  615. jsdata["art_id"] = art_id;
  616. jsdata["model_name"] = model_name;
  617. jsdata["model_info"] = model_info;
  618. jsdata["room_id"] = room_id;
  619. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  620. jsdata["user_token"] = UserInfo.User_Token;
  621. SendHttp(jsdata, success, failed);
  622. }
  623. /// <summary>
  624. /// 删除模型
  625. /// </summary>
  626. /// <param name="model_id"></param>
  627. /// <param name="success"></param>
  628. /// <param name="failed"></param>
  629. public static void DeleteModel(string model_id, Action<JsonData> success = null, Action<string> failed = null)
  630. {
  631. JsonData jsdata = new JsonData();
  632. jsdata["action"] = "20303";
  633. jsdata["model_id"] = model_id;
  634. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  635. jsdata["user_token"] = UserInfo.User_Token;
  636. SendHttp(jsdata, success, failed);
  637. }
  638. /// <summary>
  639. /// 复制模型
  640. /// </summary>
  641. /// <param name="model_id"></param>
  642. /// <param name="success"></param>
  643. /// <param name="failed"></param>
  644. public static void CopyModel(string model_id, Action<JsonData> success = null, Action<string> failed = null)
  645. {
  646. JsonData jsdata = new JsonData();
  647. jsdata["action"] = "20302";
  648. jsdata["model_id"] = model_id;
  649. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  650. jsdata["user_token"] = UserInfo.User_Token;
  651. SendHttp(jsdata, success, failed);
  652. }
  653. /// <summary>
  654. /// 编辑模型
  655. /// </summary>
  656. /// <param name="model_id"></param>
  657. /// <param name="model_info"></param>
  658. /// <param name="model_extended"></param>
  659. /// <param name="success"></param>
  660. /// <param name="failed"></param>
  661. public static void EditModel(string model_id, string model_info, string model_extended = null, Action<JsonData> success = null, Action<string> failed = null)
  662. {
  663. JsonData jsdata = new JsonData();
  664. jsdata["action"] = "20301";
  665. jsdata["model_id"] = model_id;
  666. jsdata["model_info"] = model_info;
  667. jsdata["requesttime"] = CommonMethod.GetCurrentTimeUnix().ToString();
  668. jsdata["user_token"] = UserInfo.User_Token;
  669. SendHttp(jsdata, success, failed);
  670. }
  671. }