Browse Source

更新了udp组件

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
1e46148e56
  1. 5
      Assets/UDPClient/UDPPrinter.cs
  2. 4
      Assets/UDPClient/UDPUtility.cs

5
Assets/UDPClient/UDPPrinter.cs

@ -13,7 +13,7 @@ public class UDPPrinter : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
udpUtil = new UDPUtility("127.0.0.1", 20000); udpUtil = new UDPUtility("192.168.1.41", 20000);
udpUtil.sendData("hello everyone!"); udpUtil.sendData("hello everyone!");
} }
@ -22,9 +22,6 @@ public class UDPPrinter : MonoBehaviour
{ {
if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue())) if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue()))
{ {
/*GameObject item = Instantiate(tcpMsgItem, tcpMsgContent);
item.GetComponentInChildren<Text>().text = tcpUtil.receivedData.Value;
this.GetModel<TCPEventModel>().onDataRecived.Invoke(tcpUtil.receivedData.Value);*/
Debug.Log(udpUtil.receivedData.Value); Debug.Log(udpUtil.receivedData.Value);
} }
} }

4
Assets/UDPClient/UDPUtility.cs

@ -78,7 +78,7 @@ public class UDPUtility : IUtility
public void RecciveMsg() public void RecciveMsg()
{ {
string msg = ""; string msg = "";
Debug.Log("StartReceiving!"); //Debug.Log("StartReceiving!");
while (isOpenUDP.Value) while (isOpenUDP.Value)
{ {
try try
@ -98,7 +98,7 @@ public class UDPUtility : IUtility
//断线发送异常 //断线发送异常
isTimeOut.Value = true; isTimeOut.Value = true;
exceptionData.Value = e.ToString(); exceptionData.Value = e.ToString();
break; //break;
} }
} }
Debug.Log("------------end While-------------"); Debug.Log("------------end While-------------");

Loading…
Cancel
Save