Browse Source

部分名称修改

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
58d94742b7
  1. 2
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs
  2. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs.meta
  3. 18
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs
  4. 2
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs
  5. 4
      Assets/MsgTransmitTools/src/DataEventModel.cs
  6. 2
      Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs

2
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs

@ -4,7 +4,7 @@ using UnityEngine;
using QFrameworkCP; using QFrameworkCP;
namespace JXSoft { namespace JXSoft {
public class UDPEventModel : DataEventModel public class UDPClientModel : DataEventModel
{ {
private UDPLinkState udpState = UDPLinkState.NoIp; private UDPLinkState udpState = UDPLinkState.NoIp;
private string udpAddress = ""; private string udpAddress = "";

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs.meta → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs.meta

18
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs

@ -11,7 +11,7 @@ namespace JXSoft {
protected override void Init() protected override void Init()
{ {
this.RegisterUtility(new UDPUtility()); this.RegisterUtility(new UDPUtility());
this.RegisterModel(new UDPEventModel()); this.RegisterModel(new UDPClientModel());
} }
} }
public class UDPClientView : MonoBehaviour, IController public class UDPClientView : MonoBehaviour, IController
@ -42,13 +42,13 @@ namespace JXSoft {
if (e.state == UDPLinkState.Linking) if (e.state == UDPLinkState.Linking)
{ {
Debug.Log("UDP开始链接"); Debug.Log("UDP开始链接");
this.GetModel<UDPEventModel>().linkServer(); this.GetModel<UDPClientModel>().linkServer();
} }
if (e.state == UDPLinkState.LinkSucess) if (e.state == UDPLinkState.LinkSucess)
{ {
Debug.Log("UDP链接成功"); Debug.Log("UDP链接成功");
this.GetModel<UDPEventModel>().onReceive<LinkSuccessResponse>(); this.GetModel<UDPClientModel>().onReceive<LinkSuccessResponse>();
this.GetModel<UDPEventModel>().sendRequest(new LinkUDPRequest(deviceId)); this.GetModel<UDPClientModel>().sendRequest(new LinkUDPRequest(deviceId));
onUDPLinkSuccess.Invoke(); onUDPLinkSuccess.Invoke();
} }
if (e.state == UDPLinkState.LinkFaild) if (e.state == UDPLinkState.LinkFaild)
@ -63,25 +63,25 @@ namespace JXSoft {
if (e.res.GetType() == typeof(LinkSuccessResponse)) if (e.res.GetType() == typeof(LinkSuccessResponse))
{ {
Debug.Log("Link Server success"); Debug.Log("Link Server success");
this.GetModel<UDPEventModel>().offReceive<LinkSuccessResponse>(); this.GetModel<UDPClientModel>().offReceive<LinkSuccessResponse>();
onServerConnected.Invoke(); onServerConnected.Invoke();
} }
}); });
this.GetModel<UDPEventModel>().setLinkState((int)UDPLinkState.NoIp); this.GetModel<UDPClientModel>().setLinkState((int)UDPLinkState.NoIp);
this.GetModel<UDPEventModel>().setIP(UDPAddress, UDPPort); this.GetModel<UDPClientModel>().setIP(UDPAddress, UDPPort);
} }
public void restartUDPService() public void restartUDPService()
{ {
onUDPReLink.Invoke(); onUDPReLink.Invoke();
this.GetModel<UDPEventModel>().closeServer(); this.GetModel<UDPClientModel>().closeServer();
StartCoroutine(waitTwoSecond()); StartCoroutine(waitTwoSecond());
} }
public IEnumerator waitTwoSecond() public IEnumerator waitTwoSecond()
{ {
yield return new WaitForSeconds(2.0f); yield return new WaitForSeconds(2.0f);
this.GetModel<UDPEventModel>().setLinkState((int)UDPLinkState.Linking); this.GetModel<UDPClientModel>().setLinkState((int)UDPLinkState.Linking);
} }
public IArchitecture GetArchitecture() public IArchitecture GetArchitecture()
{ {

2
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs

@ -26,7 +26,7 @@ namespace JXSoft {
{ {
GameObject item = Instantiate(udpMsgItem, udpMsgContent); GameObject item = Instantiate(udpMsgItem, udpMsgContent);
item.GetComponentInChildren<Text>().text = udpUtil.receivedData; item.GetComponentInChildren<Text>().text = udpUtil.receivedData;
this.GetModel<UDPEventModel>().onDataRecived.Invoke(udpUtil.receivedData); this.GetModel<UDPClientModel>().onDataRecived.Invoke(udpUtil.receivedData);
} }
if (udpUtil.getTimeOutState() && udpUtil.isOpenUDP) if (udpUtil.getTimeOutState() && udpUtil.isOpenUDP)

4
Assets/MsgTransmitTools/src/DataEventModel.cs

@ -70,13 +70,15 @@ namespace JXSoft {
public abstract int getLinkState(); public abstract int getLinkState();
/// <summary> /// <summary>
/// Start a link & server, you can overwrite by you own fucntions /// Start a link & server, you can override by you own fucntions
/// </summary> /// </summary>
/// <returns>is link success & server start success</returns> /// <returns>is link success & server start success</returns>
public virtual bool Start() { public virtual bool Start() {
setLinkState((int)LinkStateDefault.Open);
return true; return true;
} }
public virtual bool Close() { public virtual bool Close() {
setLinkState((int)LinkStateDefault.Close);
return true; return true;
} }
#endregion #endregion

2
Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs

@ -19,7 +19,7 @@ namespace JXSoft {
case (ProtocolType_.TCP): case (ProtocolType_.TCP):
return this.GetModel<TCPClientModel>(); return this.GetModel<TCPClientModel>();
case (ProtocolType_.UDP): case (ProtocolType_.UDP):
return this.GetModel<UDPEventModel>(); return this.GetModel<UDPClientModel>();
default: default:
return this.GetModel<TCPClientModel>(); return this.GetModel<TCPClientModel>();
} }

Loading…
Cancel
Save