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.
48 lines
1.4 KiB
48 lines
1.4 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.Events; |
|
using UnityEngine.UI; |
|
using QFrameworkCP; |
|
using System.Threading; |
|
|
|
namespace JXSoft |
|
{ |
|
public class TCPPrinter : MonoBehaviour,IController |
|
{ |
|
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); |
|
} |
|
if (tcpUtil.getTimeOutState() && tcpUtil.isOpenTCP) { |
|
this.SendEvent(new onLinkException(tcpUtil.exceptionData)); |
|
tcpUtil.isOpenTCP = false; |
|
} |
|
} |
|
private void OnDestroy() |
|
{ |
|
if (tcpUtil.reciveT != null && tcpUtil.reciveT.ThreadState == ThreadState.Running) { |
|
tcpUtil.reciveT.Abort(); |
|
} |
|
} |
|
public IArchitecture GetArchitecture() |
|
{ |
|
return TCPMangerArchitecture.Interface; |
|
} |
|
|
|
} |
|
}
|
|
|