You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
3 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Net;
|
||
|
using System.Net.Sockets;
|
||
|
using System.Text;
|
||
|
using System.Threading;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class UDPPrinter : MonoBehaviour
|
||
|
{
|
||
|
private UDPUtility udpUtil;
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
udpUtil = new UDPUtility("127.0.0.1", 20000);
|
||
|
udpUtil.sendData("hello everyone!");
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
if (udpUtil.reciveT != null && udpUtil.reciveT.ThreadState == ThreadState.Running)
|
||
|
{
|
||
|
udpUtil.reciveT.Abort();
|
||
|
}
|
||
|
}
|
||
|
}
|