/// <summary> /// 创建与服务器链接的ID /// </summary> public void ConnectPrivateByKindID() { TagGameServer tagServer = CServerListData.Instance.GetTagServerByKindID(GlobalDataScript.SSS_KIND_ID); string ip = NetUtil.BytesToString(tagServer.szServerAddr); SocketInGameEvent.Instance.ISocketEngineSink(ip, tagServer.wServerPort); }
// 登陆失败 private void OnSocketSubLogonFailure(byte[] tmpBuf, int size) { CMD_MB_LogonFailure logonError = (CMD_MB_LogonFailure)NetUtil.BytesToStruct(tmpBuf, typeof(CMD_MB_LogonFailure), size); OnGPLoginFailure(logonError.lResultCode, NetUtil.BytesToString(logonError.szDescribeString)); }
public void SetroundScore(CMD_MB_ROUND_INFO value, int dex) { info = MainNewsDataManager.instance.currentQuery; ResourcesLoader.Load <Sprite>("BaseAssets/UI_Online/Hall/UIPanel_Record/Type" + info.kindId, (sprite) => { type.sprite = sprite; type.SetNativeSize(); }); dataText.text = "第 " + (dex + 1) + " 局"; for (int i = 0; i < nameList.Count; i++) { nameStr = NetUtil.BytesToString(info.queryinfo.PersonalUserScoreInfo[i].szUserNicname); if (info.queryinfo.PersonalUserScoreInfo[i].dwUserID <= 0) { nameList[i].transform.parent.gameObject.SetActive(false); } else { nameList[i].transform.parent.gameObject.SetActive(true); nameList[i].text = NetUtil.BytesToString(info.queryinfo.PersonalUserScoreInfo[i].szUserNicname); scoreList[i].text = value.roomScore[i].IScore + ""; } } }
/* *初始化显示界面 */ private void InitUI() { var nickName = GlobalDataScript.userData.szNickName;//昵称 nickNameText.text = NetUtil.BytesToString(nickName); if (nickNameText.text.Length > 4) { nickNameText.text = nickNameText.text.Substring(0, 6).ToString() + "..."; } //MyDebug.Log("......................................." + nickNameText.text); //YinBi.text = GlobalDataScript.userData.lRoomCard.ToString(); //MyDebug.Log("......................................." + YinBi.text); //Lamuratura.text = GlobalDataScript.userData.dUserBeans.ToString(); //MyDebug.Log("......................................." + Lamuratura.text); IpText.text = GlobalDataScript.userData.dwUserID.ToString(); MyDebug.Log("......................................." + IpText.text); //GlobalDataScript.weChatInformation.id = GlobalDataScript.loginResponseData.account.uuid; //GlobalDataScript.loginResponseData.account.roomcard = roomCardcount; if (imgLoad != null) { headIconImg.sprite = imgLoad; headIconImg.preserveAspect = true; } else { StartCoroutine(LoadImg()); } }
public void ISocketEngineSinkByServerId(int serverId) { serverInfo = CServerListData.Instance.GetTagServerByServerID(serverId); socketip = NetUtil.BytesToString(serverInfo.szServerAddr); socketPort = serverInfo.wServerPort; ISocketEngineSink(); }
public void RequestFailure(byte[] buffer) { CMD_GR_RequestFailure requestFailure = NetUtil.BytesToStruct <CMD_GR_RequestFailure>(buffer); SocketEngine.Instance.SocketQuit(); MyDebug.Log("=============================请求失败====================" + NetUtil.BytesToString(requestFailure.szDescribeString)); SocketEventHandle.Instance.SetTips(NetUtil.BytesToString(requestFailure.szDescribeString)); }
//创建房间失败 public void CreateFail(byte[] tmpBuf, int size) { CMD_GR_CreateFailure createFail = NetUtil.BytesToStruct <CMD_GR_CreateFailure>(tmpBuf); SocketEventHandle.Instance.SetTips(NetUtil.BytesToString(createFail.szDescribeString)); SocketEngine.Instance.SocketQuit(); MyDebug.Log("创建房间失败" + NetUtil.BytesToString(createFail.szDescribeString)); }
//=============================读取结构方法========================// #region 读取 //创建房间时登录失败 public void LogInFail(byte[] tmpBuf, int size) { CMD_GR_CreateLogonFailure createLoginFail = NetUtil.BytesToStruct <CMD_GR_CreateLogonFailure>(tmpBuf); SocketEventHandle.Instance.SetTips(NetUtil.BytesToString(createLoginFail.szDescribeString)); SocketEngine.Instance.SocketQuit(); MyDebug.Log("###############################" + NetUtil.BytesToString(createLoginFail.szDescribeString)); MyDebug.Log("###############################" + createLoginFail.lErrorCode); }
//创建房间成功 public void CreateSuccess(byte[] tmpBuf, int size) { CMD_GR_CreateSuccess createSuccess = NetUtil.BytesToStruct <CMD_GR_CreateSuccess>(tmpBuf); MyDebug.Log("房间号" + NetUtil.BytesToString(createSuccess.szServerID)); tableId = (int)createSuccess.dwTableId; //CMD_GR_UserSitDown sitDown = new CMD_GR_UserSitDown(); //sitDown.wTableID = (ushort)tableId; //sitDown.wChairID = 0xff; //sitDown.szPassword = new byte[66]; //SocketEngine.Instance.SendScoketData((int)GameServer.MDM_GR_USER, (int)MDM_GR_USER.SUB_GR_USER_SITDOWN, NetUtil.StructToBytes(sitDown), Marshal.SizeOf(sitDown)); }
public void SetUIData() { headIcon.preserveAspect = false; headIcon.sprite = GlobalDataScript.Instance.weChatInformation.headIcon; headIcon.preserveAspect = true; id.text = GlobalDataScript.Instance.weChatInformation.id.ToString(); name.text = GlobalDataScript.Instance.weChatInformation.weChatName; ip.text = NetUtil.BytesToString(GlobalDataScript.Instance.weChatInformation.ip); sex.sprite = sexImage[GlobalDataScript.Instance.weChatInformation.sex]; sex.SetNativeSize(); sex.gameObject.GetComponent <RectTransform>().sizeDelta *= 1.5f; }
public void ConnectGameServerByServerID(int serverId) { TagGameServer tagServer = CServerListData.Instance.GetTagServerByServerID(serverId); if (tagServer.wKindID == 0) { UIManager.instance.Show(UIType.UITipsDialog, (go) => { go.GetComponent <UIPanel_TipsDialog>().SetMes("房间不存在"); }); return; } string ip = NetUtil.BytesToString(tagServer.szServerAddr); SocketInGameEvent.Instance.ISocketEngineSink(ip, tagServer.wServerPort); }
private string GetHeadHttp(byte[] bytes) { len = 0; for (int i = 0; i < bytes.Length; i++) { if (bytes[i] > 0) { len++; } } MyDebug.Log("########################Len:" + len); byte[] blist = new byte[len]; Array.Copy(bytes, blist, len); return(NetUtil.BytesToString(blist)); }
//框架命令提示消息 private void OnEventTipMessage(byte[] tmpBuf, int size) { CMD_GR_PersonalTableTip tipMessage = NetUtil.BytesToStruct <CMD_GR_PersonalTableTip>(tmpBuf); MyDebug.Log("" + NetUtil.BytesToStruct <CMD_GF_GameOptionNew>(tmpBuf)); if (GlobalDataScript.Instance.roomInfo == null) { GlobalDataScript.Instance.roomInfo = new GameRoomInfo(); } GlobalDataScript.Instance.roomInfo.roomId = NetUtil.BytesToString(tipMessage.szServerID); GlobalDataScript.Instance.roomInfo.limtNumber = tipMessage.dwDrawCountLimit.ToString(); GlobalDataScript.Instance.roomInfo.PlayGameCount = (int)tipMessage.dwPlayCount; GlobalDataScript.Instance.roomInfo.tableOwnerUserID = tipMessage.dwTableOwnerUserID;//房主 GlobalDataScript.Instance.roomInfo.InitScore = tipMessage.lCellScore; GlobalDataScript.Instance.roomInfo.InitBeishu = tipMessage.lIniScore; SocketEventHandle.Instance.SetClientResponse(APIS.SetRoomMark, null); MyDebug.Log("====================房主=====================" + GlobalDataScript.Instance.roomInfo.tableOwnerUserID); MySceneManager.instance.SceneToNiuNiu(); }
private string downloadPath; //应用下载链接 /** * 检测升级 */ public IEnumerator UpdateCheck() { WWW www = new WWW(APIS.UPDATE_INFO_JSON_URL); yield return(www); byte[] buffer = www.bytes; string returnxml = NetUtil.BytesToString(buffer); MyDebug.Log("returnxml = " + returnxml); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(returnxml); XmlNodeList nodeList = xmlDoc.SelectSingleNode("versions").ChildNodes; for (int i = 0; i < nodeList.Count; ++i) { Version123 temp = new Version123(); temp.title = nodeList[i].SelectSingleNode("title").InnerText; temp.url = nodeList[i].SelectSingleNode("url").InnerText; temp.note = nodeList[i].SelectSingleNode("note").InnerText; temp.version = nodeList[i].SelectSingleNode("versionname").InnerText; XmlElement xe = (XmlElement)nodeList[i]; if (xe.GetAttribute("id") == "ios") { serviceVersionVo.ios = temp; serviceVersionVo.ios.url += "l=zh&mt=8"; } else if (xe.GetAttribute("id") == "android") { serviceVersionVo.Android = temp; } } CompareVersion(); }
public void SetValue(QueryInfo value) { info = value; ResourcesLoader.Load <Sprite>("BaseAssets/UI_Online/Hall/UIPanel_Record/Type" + info.kindId, (sprite) => { type.sprite = sprite; type.SetNativeSize(); }); roomIdText.text = NetUtil.BytesToString(info.queryinfo.szRoomID); if (info.queryinfo.sysDissumeTime.wMonth < 10) { monthstr = "0" + info.queryinfo.sysDissumeTime.wMonth; } else { monthstr = info.queryinfo.sysDissumeTime.wMonth + ""; } if (info.queryinfo.sysDissumeTime.wDay < 10) { daystr = "0" + info.queryinfo.sysDissumeTime.wDay; } else { daystr = info.queryinfo.sysDissumeTime.wDay + ""; } if (info.queryinfo.sysDissumeTime.wwHour < 10) { hourStr = "0" + info.queryinfo.sysDissumeTime.wwHour; } else { hourStr = info.queryinfo.sysDissumeTime.wwHour + ""; } if (info.queryinfo.sysDissumeTime.wSecond < 10) { secondstr = "0" + info.queryinfo.sysDissumeTime.wSecond; } else { secondstr = "" + info.queryinfo.sysDissumeTime.wSecond; } if (info.queryinfo.sysDissumeTime.wMinute < 10) { millistr = "0" + info.queryinfo.sysDissumeTime.wMinute; } else { millistr = "" + info.queryinfo.sysDissumeTime.wMinute; } dataText.text = info.queryinfo.sysDissumeTime.wYear + "-" + monthstr + "-" + daystr; timeText.text = hourStr + ":" + millistr + ":" + secondstr; for (int i = 0; i < nameList.Count; i++) { nameStr = NetUtil.BytesToString(info.queryinfo.PersonalUserScoreInfo[i].szUserNicname); if (info.queryinfo.PersonalUserScoreInfo[i].dwUserID <= 0) { nameList[i].transform.parent.gameObject.SetActive(false); } else { nameList[i].transform.parent.gameObject.SetActive(true); nameList[i].text = NetUtil.BytesToString(info.queryinfo.PersonalUserScoreInfo[i].szUserNicname); scoreList[i].text = info.queryinfo.PersonalUserScoreInfo[i].lScore + ""; } } }
private void OnSubGameEnd(byte[] tmpBuf, int size) { MyDebug.Log("OnSubGameEnd Size==" + size); MyDebug.Log(NetUtil.BytesToString(tmpBuf)); var pGameEnd = NetUtil.BytesToStruct <CMD_S_GameEnd>(tmpBuf); // MyDebug.Log("OnSubGameEnd---:" + pGameEnd.bAllGameEnd + "????????????????????????????????????????????"); var gnv = new HupaiResponseVo(); // for (int i = 0; i < pGameEnd.cbCardCount.Length; i++) // { // var hupaiResponseItem = new HupaiResponseItem // { // chairId = i // }; // if (i == pGameEnd.wChiHuUser) // { // hupaiResponseItem.win = true; // var card = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.cb_hu_card); // var huInfo = new HuInfo // { // card = card // }; // hupaiResponseItem.huInfo = huInfo; // } // else // { // hupaiResponseItem.win = false; // } // hupaiResponseItem.roundTotalScore = (int)pGameEnd.lGameScore[i]; // for (int j = 0; j < pGameEnd.cbWeaveCount[i]; j++) // { // if (pGameEnd.WeaveItemArray[i].WeaveItem[j].cbWeaveKind == 16) // { // var gangInfo = new GangInfo // { // cardIndex = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.WeaveItemArray[i].WeaveItem[j].cbCenterCard) // }; // hupaiResponseItem.gangInfos.Add(gangInfo); // } // else if (pGameEnd.WeaveItemArray[i].WeaveItem[j].cbWeaveKind == 8) // { // var card = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.WeaveItemArray[i].WeaveItem[j].cbCenterCard); // hupaiResponseItem.pengArray.Add(card); // } // else if (pGameEnd.WeaveItemArray[i].WeaveItem[j].cbWeaveKind == 2) // { // var card = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.WeaveItemArray[i].WeaveItem[j].cbCenterCard); // hupaiResponseItem.centerChiArray.Add(card); // } // else if (pGameEnd.WeaveItemArray[i].WeaveItem[j].cbWeaveKind == 4) // { // var card = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.WeaveItemArray[i].WeaveItem[j].cbCenterCard); // hupaiResponseItem.rightChiArray.Add(card); // } // else if (pGameEnd.WeaveItemArray[i].WeaveItem[j].cbWeaveKind == 1) // { // var card = MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.WeaveItemArray[i].WeaveItem[j].cbCenterCard); // hupaiResponseItem.leftChiArray.Add(card); // } // } // for (int k = 0; k < pGameEnd.cbCardCount[i]; k++) // { // hupaiResponseItem.paiArray.Add(MaJiangHelper.MaJiangCardChange((MJ_PAI)pGameEnd.cbCardData[i].cbCardData[k])); // } // gnv.avatarList.Add(hupaiResponseItem); // } // gnv.endType = pGameEnd.dwChiHuRight; // gnv.bAllGameEnd = pGameEnd.bAllGameEnd == 1 ? true : false; // SetClientResponse(APIS.HUPAI_RESPONSE, NetUtil.ObjToJson(gnv)); //} }