NetWorkHeaders.cs 25 KB

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