HttpDistribute.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. using System.Collections.Generic;
  2. using Engine.Http;
  3. //using ThoughtWorks.QRCode.Codec;
  4. using System.Net.NetworkInformation;
  5. using UnityEngine;
  6. using System.IO;
  7. //using System.Drawing;
  8. using System.Text;
  9. //using System.Drawing.Imaging;
  10. using System;
  11. using LitJson;
  12. public delegate void HanlderNetException(int command, string msg);
  13. public delegate void HandlerNetDistributeQRCode(Texture2D texture);
  14. namespace Engine.Http
  15. {
  16. public class HttpPlayer
  17. {
  18. public string name;
  19. public int pid;
  20. public int machineID;
  21. public int score;
  22. public string wechat;
  23. public string avatarFile;
  24. public int rank;
  25. public Dictionary<int, PlayerStage> playerStages = new Dictionary<int, PlayerStage>();
  26. public HttpPlayer()
  27. {
  28. }
  29. public void SetPlayerData(JsonData data)
  30. {
  31. name = data["name"].ToString();
  32. wechat = data["wechat"].ToString();
  33. avatarFile = data["avatar_file"].ToString();
  34. score = System.Convert.ToInt32(data["score"].ToString());
  35. pid = (int)data["pid"];
  36. machineID = (int)data["machine_id"];
  37. }
  38. public void SetRankData(JsonData data)
  39. {
  40. name = data["name"].ToString();
  41. score = System.Convert.ToInt32(data["score"].ToString());
  42. if(data["rank"] != null)
  43. {
  44. rank = (int)data["rank"];
  45. }
  46. }
  47. public void AddStagePoint(int stageID, int star, int score, string stageTime)
  48. {
  49. PlayerStage stage;
  50. if(!playerStages.ContainsKey(stageID))
  51. {
  52. stage = new PlayerStage();
  53. playerStages.Add(stageID, stage);
  54. }
  55. else
  56. {
  57. stage = playerStages[stageID];
  58. }
  59. stage.score = score;
  60. stage.star = star;
  61. stage.stageTime = stageTime;
  62. }
  63. }
  64. public class PlayerStage
  65. {
  66. public int star;
  67. public int score;
  68. public string stageTime;
  69. }
  70. /// <summary>
  71. /// 网络通信分发类
  72. ///
  73. /// add by ch.ji
  74. ///
  75. /// </summary>
  76. public class HttpDistribute : System.Object
  77. {
  78. /// <summary>二维码分辨率精度</summary>
  79. public const int QR_CODE_SCALE = 1;
  80. #region 单例
  81. /// <summary>单利对象</summary>
  82. private static HttpDistribute instance;
  83. /// <summary>获得单利对象</summary>
  84. public static HttpDistribute Instance
  85. {
  86. get
  87. {
  88. if (instance == null)
  89. {
  90. return instance = new HttpDistribute();
  91. }
  92. return instance;
  93. }
  94. }
  95. #endregion
  96. #region 网络通讯基本参数配置
  97. private string mGateWay = "";
  98. private string mPort = "";
  99. private string mHost = "";
  100. private string mHostBMSGame = "";
  101. private int mGameType = 0;
  102. private int mMachineID = 0;
  103. private int mCurrentPID = -1;
  104. private int mHID = -1;
  105. #endregion
  106. #region 私有属性
  107. /// <summary>是否开启轮询方式获取等待中的玩家</summary>
  108. private bool IsPollingWaitingPlayers = true;
  109. /// <summary>轮询获取等待中玩家的周期</summary>
  110. private int mPWPTimeMax = 10 * 1000;
  111. /// <summary>心跳检测连接的的时间周期</summary>
  112. private int mNetTicTimeMax = 10 * 1000;
  113. /// <summary>网络连接是否已断开</summary>
  114. private bool isConnecting = false;
  115. /// <summary>http网络请求管理器引用</summary>
  116. private HttpManager httpManager = HttpManager.GetInstance();
  117. /// <summary>HTTP网络请求缓存</summary>
  118. private Dictionary<string, HttpRequest> httpRequestCache = new Dictionary<string, HttpRequest>();
  119. /// <summary>等待中的玩家列表</summary>
  120. private ObjectArray mWaitingPlayers = new ObjectArray(1000);
  121. /// <summary>排行榜</summary>
  122. private ObjectArray mRankPlayers = new ObjectArray(20);
  123. /// <summary>当前正玩游戏的玩家(列表中第一位)</summary>
  124. private HttpPlayer mCurrentPlayer = new HttpPlayer();
  125. /// <summary>与服务端通信使用的物理地址</summary>
  126. private string mMacAddress;
  127. #endregion
  128. #region 外部可设置的回调函数
  129. /// <summary>请求返回值异常回调函数</summary>
  130. private HanlderNetException mOnNetExceptionHandler;
  131. /// <summary>获取二维码的外部回调函数</summary>
  132. private HandlerNetDistributeQRCode mOnQRCodeHandler;
  133. /// <summary>轮询获取到等待中玩家的外部回调函数</summary>
  134. private HandleHttpMessage mPollingWaitingPlayers;
  135. /// <summary>HTTP请求外部回调函数</summary>
  136. private HandleHttpMessage mHttpMessage;
  137. #endregion
  138. /// <summary>
  139. /// 构造函数
  140. /// </summary>
  141. public HttpDistribute()
  142. {
  143. }
  144. /// <summary>
  145. /// 初始化http网络请求分发器,入口
  146. /// </summary>
  147. /// <param name="gateWay"></param>
  148. /// <param name="port"></param>
  149. /// <param name="type"></param>
  150. /// <param name="callback"></param>
  151. public void Init(string gateWay, int type, int port = -1)
  152. {
  153. mGateWay = gateWay;
  154. mPort = port.ToString();
  155. mHost = (port == -1) ? mGateWay : mGateWay + mPort;
  156. mHostBMSGame = mHost + "/bms/game/";
  157. mGameType = type;
  158. httpManager.AddHttpMessageEvent(OnNetDistributeSend);
  159. }
  160. #region 添加和删除外部回调函数
  161. public void AddQRCodeHandler(HandlerNetDistributeQRCode handler)
  162. {
  163. mOnQRCodeHandler += handler;
  164. }
  165. public void RemoveQRCodeHandler(HandlerNetDistributeQRCode handler)
  166. {
  167. mOnQRCodeHandler -= handler;
  168. }
  169. public void AddWaitingPlayersHanlder(HandleHttpMessage handler)
  170. {
  171. mPollingWaitingPlayers += handler;
  172. }
  173. public void RemoveWaitingPlayersHanlder(HandleHttpMessage handler)
  174. {
  175. mPollingWaitingPlayers -= handler;
  176. }
  177. public void AddHttpMessageHandler(HandleHttpMessage handler)
  178. {
  179. mHttpMessage += handler;
  180. }
  181. public void RemoveHttpMessageHandler(HandleHttpMessage handler)
  182. {
  183. mHttpMessage -= handler;
  184. }
  185. public void AddNetExceptionHandler(HanlderNetException handler)
  186. {
  187. mOnNetExceptionHandler += handler;
  188. }
  189. public void RemoveNetExceptionHandler(HanlderNetException handler)
  190. {
  191. mOnNetExceptionHandler -= handler;
  192. }
  193. #endregion
  194. private string GetHostBMSGameURL(string serverMethodName)
  195. {
  196. StringBuilder url = new StringBuilder(mHostBMSGame);
  197. url.Append(serverMethodName);
  198. return url.ToString();
  199. }
  200. private bool hasRequestCache(string url)
  201. {
  202. return httpRequestCache.ContainsKey(url);
  203. }
  204. /// <summary>
  205. /// 发送获取支付二维码的http请求
  206. /// </summary>
  207. /// <param name="callback"></param>
  208. public void GetPayQRCodeHTTP()
  209. {
  210. string url = GetHostBMSGameURL(ServerMethod.SERVER_QRCODE);
  211. HttpRequest request = CreateRequest(url, (int)HTTPClientCommand.CMD_GET_QRCODE);
  212. Send(request);
  213. }
  214. #region 获取二维码
  215. /// <summary>
  216. /// 获取支付二维码的回调函数
  217. /// </summary>
  218. /// <param name="result"></param>
  219. private void OnGetQRCode(HttpResponse result)
  220. {
  221. /*mMacAddress = result.ReadJsonData("mac").ToString();
  222. string QRData = result.ReadJsonData("code").ToString();
  223. QRCodeEncoder encoder = new QRCodeEncoder();
  224. encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;//编码方式(注意:BYTE能支持中文,ALPHA_NUMERIC扫描出来的都是数字)
  225. encoder.QRCodeScale = QR_CODE_SCALE;//大小(值越大生成的二维码图片像素越高)
  226. encoder.QRCodeVersion = 0;//版本(注意:设置为0主要是防止编码的字符串太长时发生错误)
  227. encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;//错误效验、错误更正(有4个等级)
  228. Bitmap bmp = encoder.Encode(QRData, System.Text.Encoding.UTF8);
  229. Texture2D texture = CreateQRCodeTexture(bmp);
  230. if (mOnQRCodeHandler != null)
  231. mOnQRCodeHandler(texture);
  232. isConnecting = true;
  233. IsPollingWaitingPlayers = true;//开始轮询检测等待中的玩家
  234. PollingWaitingPlayers(null);*/
  235. }
  236. /// <summary>
  237. /// 创建支付二维码
  238. /// </summary>
  239. /// <param name="bmp"></param>
  240. /// <returns></returns>
  241. /*private Texture2D CreateQRCodeTexture(Bitmap bmp)
  242. {
  243. Texture2D texture = new Texture2D(bmp.Width, bmp.Height, TextureFormat.RGBA32, false);
  244. UnityEngine.Color zeroColor = new UnityEngine.Color(0, 0, 0, 1f);
  245. for (int i = 0; i < bmp.Width; i++)
  246. {
  247. for (int j = 0; j < bmp.Height; j++)
  248. {
  249. System.Drawing.Color sysColor = bmp.GetPixel(i, j);
  250. int r = (int)sysColor.R;
  251. int g = (int)sysColor.G;
  252. int b = (int)sysColor.B;
  253. int a = (int)sysColor.A;
  254. if (r != 0 || g != 0 || b != 0 || a != 0)
  255. {
  256. float fr = (r != 0) ? r / 255f : 0f;
  257. float fg = (g != 0) ? g / 255f : 0f;
  258. float fb = (b != 0) ? b / 255f : 0f;
  259. float fa = (a != 0) ? a / 255f : 0f;
  260. UnityEngine.Color color = new UnityEngine.Color(fr, fg, fb, fa);
  261. texture.SetPixel(i, j, color);
  262. }
  263. else
  264. {
  265. texture.SetPixel(i, j, zeroColor);
  266. }
  267. }
  268. }
  269. texture.Apply();
  270. return texture;
  271. }*/
  272. #endregion
  273. /// <summary>
  274. /// 发送获取等待中的玩家列表的http请求
  275. /// </summary>
  276. /// <param name="isForPolling"></param>
  277. public void GetWaitingPlayersHTTP()
  278. {
  279. GetWaitingPlayersHTTP((int)HTTPClientCommand.CMD_GET_WAITING_PLAYERS);
  280. }
  281. #region 获取等待中玩家,包括轮询
  282. /// <summary>
  283. /// 轮询获取等待中玩家列表
  284. /// </summary>
  285. /// <param name="nTime"></param>
  286. private void GetWaitingPlayersHTTP(int command)
  287. {
  288. string url = GetHostBMSGameURL(ServerMethod.GET_PLAYER_LIST);
  289. HttpRequest request = null;
  290. if (!hasRequestCache(url))
  291. {
  292. request = CreateRequest(url, command);
  293. httpRequestCache.Add(url, request);
  294. } else
  295. {
  296. request = httpRequestCache[url];
  297. }
  298. if (command != request.Code)
  299. request.Code = command;
  300. Send(request);
  301. httpRequestCache[url].ResetRequestParamContent();
  302. }
  303. /// <summary>
  304. /// 轮询中获取到等待的玩家列表时的处理
  305. /// </summary>
  306. /// <param name="result"></param>
  307. private void OnGetWaitingPlayers(HttpResponse result)
  308. {
  309. IsPollingWaitingPlayers = false;
  310. JsonData data = result.ReadJsonData();
  311. if (data.IsArray)
  312. {
  313. HttpPlayer target = null;
  314. JsonData player = null;
  315. mWaitingPlayers.SetEmpty();
  316. for (int i = 0; i < data.Count; i++)
  317. {
  318. if (i >= mWaitingPlayers.Length)
  319. break;
  320. player = data[i];
  321. target = new HttpPlayer();
  322. target.SetPlayerData(player);
  323. mWaitingPlayers.Add(target);
  324. }
  325. target = mWaitingPlayers.Get<HttpPlayer>(0);
  326. //target.AddStagePoint(player)//TODO 增加关卡数据的保存逻辑
  327. IsPollingWaitingPlayers = (target == null);
  328. if (IsPollingWaitingPlayers)
  329. {
  330. mCurrentPID = -1;
  331. mMachineID = -1;
  332. TimerManager.Instance.WaitCallBack(mPWPTimeMax, PollingWaitingPlayers);
  333. } else
  334. {
  335. mCurrentPID = target.pid;
  336. mMachineID = target.machineID;
  337. TimerManager.Instance.WaitCallBack(mNetTicTimeMax, CheckNetStatuTic);
  338. }
  339. }
  340. if (mPollingWaitingPlayers != null)
  341. {
  342. mPollingWaitingPlayers(result);
  343. }
  344. }
  345. private void PollingWaitingPlayers(object param)
  346. {
  347. if (isConnecting && IsPollingWaitingPlayers)
  348. {
  349. GetWaitingPlayersHTTP((int)HTTPClientCommand.CMD_POLLING_WAITING_PLAYERS);
  350. }
  351. }
  352. #endregion
  353. /// <summary>
  354. /// 发送开始游戏的http请求
  355. /// </summary>
  356. public void StartGameHTTP()
  357. {
  358. if (mCurrentPID == -1)
  359. return;
  360. string url = GetHostBMSGameURL(ServerMethod.SERVER_START_GAME);
  361. HttpRequest request = CreateRequest(url, (int)HTTPClientCommand.CMD_START_GAME);
  362. request.AddParam("pid", mCurrentPID.ToString());
  363. request.AddParam("machine_id", mMachineID.ToString());
  364. Send(request);
  365. }
  366. /// <summary>
  367. /// 游戏结束,发送游戏结果的http请求
  368. /// </summary>
  369. public void CommitGameHTTP(int stageID, int score, int machineID = -1, int pID = -1, int hId = -1)
  370. {
  371. if (hId == -1)
  372. hId = mHID;
  373. if (machineID == -1)
  374. machineID = mMachineID;
  375. if (pID == -1)
  376. pID = mCurrentPID;
  377. if (pID == -1 || machineID == -1 || hId == -1)
  378. {
  379. CDebug.Log("Http Distribute: hid、pid、machine_id 可能不正确,游戏数据提交失败!");
  380. return;
  381. }
  382. StringBuilder content = new StringBuilder();
  383. JsonWriter writer = new JsonWriter(content);
  384. writer.WriteObjectStart();
  385. writer.WritePropertyName("game_type");//必备参数
  386. writer.Write(mGameType.ToString());
  387. writer.WritePropertyName("machine_id");//必备参数
  388. writer.Write(machineID.ToString());
  389. writer.WritePropertyName("pid");//用户id
  390. writer.Write(pID.ToString());
  391. writer.WritePropertyName("stage_id");//关卡id
  392. writer.Write(stageID.ToString());
  393. writer.WritePropertyName("score");//关卡分数
  394. writer.Write(score.ToString());
  395. writer.WritePropertyName("hid");//区分游玩关卡的次数id
  396. writer.Write(hId.ToString());
  397. writer.WriteObjectEnd();
  398. string jsonParams = content.ToString();
  399. string url = GetHostBMSGameURL(ServerMethod.SERVER_COMMIT_GAME);
  400. HttpRequest request = CreateRequest(url, (int)HTTPClientCommand.CMD_COMMIT_GAME, HttpMethod.POST);
  401. request.SetJSONParamContent(jsonParams);
  402. Send(request, false);
  403. }
  404. /// <summary>
  405. /// 获取玩家排行榜
  406. /// </summary>
  407. /// <param name="pID"></param>
  408. public void GetRankHTTP(int pID = -1)
  409. {
  410. if(pID == -1)
  411. pID = mCurrentPID;
  412. if (pID == -1)
  413. return;
  414. string url = GetHostBMSGameURL(ServerMethod.SERVER_GET_RANK);
  415. HttpRequest request = CreateRequest(url, (int)HTTPClientCommand.CMD_GET_RANK);
  416. request.AddParam("pid", pID.ToString());
  417. Send(request);
  418. }
  419. /// <summary>
  420. /// 发送HTTP网络请求
  421. /// </summary>
  422. /// <param name="request"></param>
  423. /// <param name="applyBaseParams"></param>
  424. public void Send(HttpRequest request, bool applyBaseParams = true)
  425. {
  426. if (applyBaseParams)
  427. {
  428. request.AddParam("mac", MacAddress);//添加基本通信参数
  429. request.AddParam("game_type", GameTypeParam);
  430. }
  431. httpManager.SendMessage(request);//发送网络请求
  432. }
  433. #region 网络连接心跳检测
  434. private void CheckNetStatuTic(object param)
  435. {
  436. if (isConnecting && !IsPollingWaitingPlayers)
  437. {
  438. CheckNetStatuHTTP();
  439. }
  440. }
  441. private void CheckNetStatuHTTP()
  442. {
  443. string url = mHostBMSGame;
  444. HttpRequest request = null;
  445. if (!hasRequestCache(url))
  446. {
  447. request = CreateRequest(url, (int)HTTPClientCommand.CMD_CHECK_NETSTATU);
  448. httpRequestCache.Add(url, request);
  449. }else
  450. {
  451. request = httpRequestCache[url];
  452. }
  453. Send(request);
  454. httpRequestCache[url].ResetRequestParamContent();
  455. }
  456. private void OnCheckNetStatu(HttpResponse responder)
  457. {
  458. if (!responder.isSuccess)
  459. {
  460. isConnecting = false;
  461. //TODO 提示网络已断开
  462. }else
  463. {
  464. if(!IsPollingWaitingPlayers)
  465. {
  466. TimerManager.Instance.WaitCallBack(mNetTicTimeMax, CheckNetStatuTic);
  467. }
  468. }
  469. }
  470. #endregion
  471. /// <summary>
  472. /// 处理排行榜返回值
  473. /// </summary>
  474. /// <param name="result"></param>
  475. private void OnGetRank(HttpResponse result)
  476. {
  477. JsonData list = result.ReadJsonData("top_list");//{"name":"", "avatar_file":"", "pid":"", "wechat":""}
  478. JsonData playerData = result.ReadJsonData("player_data");//{"name":"", "avatar_file":"", "pid":"", "wechat":"", "rank":""}
  479. mCurrentPlayer.SetRankData(playerData);
  480. mRankPlayers.SetEmpty();
  481. if (list.IsArray)
  482. {
  483. JsonData target = null;
  484. HttpPlayer player = null;
  485. for (int i = 0; i < list.Count; i++)
  486. {
  487. if (i >= mRankPlayers.Length)
  488. break;
  489. target = list[i];
  490. player = new HttpPlayer();
  491. player.SetRankData(target);
  492. mRankPlayers.Add(player);
  493. }
  494. CDebug.Log ("排行榜信息拿到");
  495. //MessageCenter.Instance.Broadcast(GameEnum.MSG_GET_RANK_INFO_CALLBACK);
  496. }
  497. }
  498. #region 每帧检测的内容
  499. public void OnUpdate(int nTime)
  500. {
  501. if (httpManager != null)
  502. httpManager.OnUpdate(nTime);
  503. }
  504. public void OnFixedUpdate(int nTime)
  505. {
  506. if (httpManager != null)
  507. httpManager.OnFixedUpdate(nTime);
  508. }
  509. #endregion
  510. #region 统一发送、响应请求
  511. private HttpRequest CreateRequest(string url, int command, string method = HttpMethod.GET)
  512. {
  513. HttpRequest result = HttpRequest.OnCreateRequest();//构建网络请求对象
  514. result.URL = url;
  515. result.Code = command;
  516. result.httpMethod = method;
  517. //request.requestTimeout = OnNetDistributeRequestTimeOut;//请求超时的回调函数
  518. return result;
  519. }
  520. /// <summary>
  521. /// 统一处理网络请求返回值
  522. /// </summary>
  523. /// <param name="result"></param>
  524. /// <returns></returns>
  525. private bool OnNetDistributeSend(HttpResponse result)
  526. {
  527. bool isSuccess = false;
  528. if (result != null && result.isSuccess)
  529. {
  530. isSuccess = true;
  531. int command = result.Code;
  532. switch (result.Code)
  533. {
  534. case (int)HTTPClientCommand.CMD_GET_QRCODE:
  535. OnGetQRCode(result);
  536. break;
  537. case (int)HTTPClientCommand.CMD_START_GAME:
  538. mHID = (int)result.ReadJsonData("hid");
  539. break;
  540. case (int)HTTPClientCommand.CMD_POLLING_WAITING_PLAYERS:
  541. OnGetWaitingPlayers(result);
  542. break;
  543. case (int)HTTPClientCommand.CMD_CHECK_NETSTATU:
  544. OnCheckNetStatu(result);
  545. break;
  546. case (int)HTTPClientCommand.CMD_GET_RANK:
  547. OnGetRank(result);
  548. break;
  549. case (int)HTTPClientCommand.CMD_COMMIT_GAME:
  550. GetWaitingPlayersHTTP((int)HTTPClientCommand.CMD_POLLING_WAITING_PLAYERS);//提交完分数后再获取一次玩家的等待列表
  551. return true;
  552. default:
  553. break;
  554. }
  555. if (mHttpMessage != null)
  556. mHttpMessage(result);//网络请求结果分发
  557. }
  558. else
  559. {
  560. isSuccess = false;
  561. if(result != null)
  562. {
  563. if (result.ResponseMsg != null)
  564. {
  565. //TODO 异常消息推送
  566. CDebug.Log("请求发生异常!=========================================");
  567. if (mOnNetExceptionHandler != null)
  568. mOnNetExceptionHandler(result.Code, result.ResponseMsg);
  569. }
  570. }else
  571. {
  572. CDebug.Log("处理返回值对象为NULL!");
  573. }
  574. }
  575. return isSuccess;
  576. }
  577. public void OnNetDistributeRequestTimeOut(HttpRequest request)
  578. {
  579. }
  580. #endregion
  581. #region 属性 getter/setter
  582. public string MacAddress
  583. {
  584. get
  585. {
  586. if(mMacAddress == null)
  587. {
  588. NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
  589. ObjectArray list = new ObjectArray(nis.Length);
  590. StringBuilder result = new StringBuilder("");
  591. string str;
  592. int i = 0;
  593. int max = nis.Length;
  594. while (i < max)
  595. {
  596. str = nis[i].GetPhysicalAddress().ToString();
  597. if (list.IndexOf(str) == -1 && str != "" && str != "00000000000000E0")
  598. {
  599. list.Add(str);
  600. result.Append(str);
  601. result.Append(",");
  602. }
  603. i++;
  604. }
  605. result.Remove(result.Length - 1, 1);
  606. mMacAddress = result.ToString();
  607. }
  608. return mMacAddress;
  609. }
  610. }
  611. public string GameTypeParam
  612. {
  613. get
  614. {
  615. return mGameType.ToString();
  616. }
  617. }
  618. public string Host
  619. {
  620. get
  621. {
  622. return mHost;
  623. }
  624. }
  625. public int pollingWaitingPlayerTimeMax
  626. {
  627. get
  628. {
  629. return mPWPTimeMax;
  630. }
  631. set
  632. {
  633. mPWPTimeMax = value;
  634. }
  635. }
  636. public int netTicTimeMax
  637. {
  638. get
  639. {
  640. return mNetTicTimeMax;
  641. }
  642. set
  643. {
  644. mNetTicTimeMax = value;
  645. }
  646. }
  647. public ObjectArray waitingPlayers
  648. {
  649. get
  650. {
  651. return mWaitingPlayers;
  652. }
  653. }
  654. public ObjectArray rankPlayers
  655. {
  656. get
  657. {
  658. return mRankPlayers;
  659. }
  660. }
  661. public int hID
  662. {
  663. get
  664. {
  665. return mHID;
  666. }
  667. }
  668. #endregion
  669. }
  670. }