//同步IP void UpdateSyncIpConnect() { byte[] ipData = null; if (syncIpConnection != null) { ipData = syncIpConnection.GetMsg(); } //接受同步IP if (recvBroadCastIP == true) { if (ipData != null) { string recvIpString = Encoding.UTF8.GetString(ipData); string[] strSplit = recvIpString.Split('|'); if (strSplit.Length == 3) { string version = strSplit[0]; string ip = strSplit[1]; string group = strSplit[2]; if (version == Application.version && netGroup == group) { recvBroadCastIP = false; syncIpConnection.Dispose(); syncIpConnection = null; ConenctTcp(ip); } } } } }
void Update() { byte[] udpMsg = sendUdp.GetMsg(); if (udpMsg != null) { string recvString = System.Text.ASCIIEncoding.ASCII.GetString(udpMsg); if (debugMsg) { Debug.Log(recvString); } if (recvString.StartsWith("Btn:")) { string btnResult = recvString.Replace("Btn:", ""); string[] btnSplit = btnResult.Split(','); for (byte i = 0; i < btnSplit.Length; i++) { byte lastStatus = btnStatus[i]; byte inputStatus; if (byte.TryParse(btnSplit[i], out inputStatus)) { if (lastStatus != inputStatus) { btnStatus[i] = inputStatus; OnBtnChange(i, btnStatus[i]); } } } } } }
/// <summary> /// 处理多数据消息 /// </summary> void HandleMutiDataMsg() { if (multidataConnection != null) { byte[] data = multidataConnection.GetMsg(); DeserializeMsg(data); } }