using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
public class UDPManager : MonoBehaviour
{
class UDPData
{
private readonly UdpClient udpClient;
public UdpClient UDPClient
{
get { return udpClient; }
}
private readonly IPEndPoint endPoint;
public IPEndPoint EndPoint
{
get { return endPoint; }
}
//构造函数
public UDPData(IPEndPoint endPoint, UdpClient udpClient)
{
this.endPoint = endPoint;
this.udpClient = udpClient;
}
}
string receiveData = string.Empty;
private Action<string> ReceiveCallBack = null;
private Thread RecviveThread;
private void Start()
{
//开启线程
ThreadRecvive();
}
private void Update()
{
if (ReceiveCallBack != null &&
Unity接收和发送UDP信号(使用UdpClient)
最新推荐文章于 2024-05-16 10:16:54 发布