金铉Unity插件库 Unity版本2018.4.32f 目前包含本地化存储功能(根据类名存储读写),TCP客户端监听类型功能
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.

49 lines
1.4 KiB

2 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using QFrameworkCP;
2 years ago
using System.Threading;
namespace JXSoft
2 years ago
{
public class TCPPrinter : MonoBehaviour,IController
2 years ago
{
private TCPUtility tcpUtil;
public Transform tcpMsgContent;
public GameObject tcpMsgItem;
void Awake()
{
tcpUtil = GetArchitecture().GetUtility<TCPUtility>();
}
// Update is called once per frame
void Update()
{
//Debug.Log(tcpUtil.Read_TCPClient());
if (tcpUtil != null && !"".Equals(tcpUtil.getReceivedValue())) {
GameObject item = Instantiate(tcpMsgItem, tcpMsgContent);
item.GetComponentInChildren<Text>().text = tcpUtil.receivedData;
this.GetModel<TCPEventModel>().onDataRecived.Invoke(tcpUtil.receivedData);
2 years ago
}
if (tcpUtil.getTimeOutState() && tcpUtil.isOpenTCP) {
this.SendEvent(new onLinkException(tcpUtil.exceptionData));
tcpUtil.isOpenTCP = false;
2 years ago
}
}
private void OnDestroy()
{
if (tcpUtil.reciveT != null && tcpUtil.reciveT.ThreadState == ThreadState.Running) {
tcpUtil.reciveT.Abort();
}
}
public IArchitecture GetArchitecture()
{
return TCPMangerArchitecture.Interface;
}
}
}