Browse Source

修改名称

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
d927a6e952
  1. 20
      Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs
  2. 6
      Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs
  3. 7
      Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs

20
Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs

@ -21,13 +21,13 @@ namespace JXSoft
{ {
this.RegisterEvent<onLinkException>(e=> { this.RegisterEvent<onLinkException>(e=> {
setLinkState((int)TCPLinkState.LinkTimeOut); setLinkState((int)TCPLinkState.LinkTimeOut);
this.GetUtility<TCPUtility>().CloseTCPClient(); this.GetUtility<TCPClientUtility>().CloseTCPClient();
}); });
//注册重写发送事件 //注册重写发送事件
this.RegisterEvent<RequestMsgEvent>(e => { this.RegisterEvent<RequestMsgEvent>(e => {
if (this.GetUtility<TCPUtility>().isOpenTCP) if (this.GetUtility<TCPClientUtility>().isOpenTCP)
{ {
this.GetUtility<TCPUtility>().sendData(e.req.toProtocolData()); this.GetUtility<TCPClientUtility>().sendData(e.req.toProtocolData());
} }
else else
{ {
@ -70,9 +70,9 @@ namespace JXSoft
public void linkServer() { public void linkServer() {
if (tcpState == TCPLinkState.Linking) if (tcpState == TCPLinkState.Linking)
{ {
if (!this.GetUtility<TCPUtility>().isOpenTCP) { if (!this.GetUtility<TCPClientUtility>().isOpenTCP) {
bool isSuccess = this.GetUtility<TCPUtility>().StartTCPClient(tcpAddress, tcpPort); bool isSuccess = this.GetUtility<TCPClientUtility>().StartTCPClient(tcpAddress, tcpPort);
if (isSuccess) { if (isSuccess) {
setLinkState((int)TCPLinkState.LinkSucess); setLinkState((int)TCPLinkState.LinkSucess);
} }
@ -90,10 +90,10 @@ namespace JXSoft
{ {
if (tcpState == TCPLinkState.LinkSucess) if (tcpState == TCPLinkState.LinkSucess)
{ {
if (this.GetUtility<TCPUtility>().isOpenTCP) if (this.GetUtility<TCPClientUtility>().isOpenTCP)
{ {
this.GetUtility<TCPUtility>().CloseTCPClient(); this.GetUtility<TCPClientUtility>().CloseTCPClient();
setLinkState((int)TCPLinkState.NoIp); setLinkState((int)TCPLinkState.NoIp);
} }
} }
@ -126,7 +126,7 @@ namespace JXSoft
#endregion #endregion
#region util #region util
public class TCPUtility : IUtility public class TCPClientUtility : IUtility
{ {
public string tcpAddress; public string tcpAddress;
public int tcpPort; public int tcpPort;
@ -140,12 +140,12 @@ namespace JXSoft
public Thread reciveT; public Thread reciveT;
public bool isTimeOut = false; public bool isTimeOut = false;
public TCPUtility() public TCPClientUtility()
{ {
Debug.LogWarning("使用无参数构造tcp时,需要手动开启tcp服务"); Debug.LogWarning("使用无参数构造tcp时,需要手动开启tcp服务");
} }
public TCPUtility(string tcpAddress, int tcpPort) public TCPClientUtility(string tcpAddress, int tcpPort)
{ {
this.tcpAddress = tcpAddress; this.tcpAddress = tcpAddress;
this.tcpPort = tcpPort; this.tcpPort = tcpPort;

6
Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs

@ -13,14 +13,14 @@ namespace JXSoft {
{ {
protected override void Init() protected override void Init()
{ {
this.RegisterUtility(new TCPUtility()); this.RegisterUtility(new TCPClientUtility());
this.RegisterModel(new TCPClientModel()); this.RegisterModel(new TCPClientModel());
} }
} }
public class TCPClientView : MonoBehaviour,IController,ICanRegisterEvent public class TCPClientView : MonoBehaviour,IController,ICanRegisterEvent
{ {
//Printer&MsgGetter //Printer&MsgGetter
private TCPUtility tcpUtil; private TCPClientUtility tcpUtil;
public Transform tcpMsgContent; public Transform tcpMsgContent;
public GameObject tcpMsgItem; public GameObject tcpMsgItem;
@ -38,7 +38,7 @@ namespace JXSoft {
{ {
initTCPService(); initTCPService();
DontDestroyOnLoad(this); DontDestroyOnLoad(this);
tcpUtil = GetArchitecture().GetUtility<TCPUtility>(); tcpUtil = GetArchitecture().GetUtility<TCPClientUtility>();
} }
public void initTCPService() { public void initTCPService() {

7
Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs

@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace JXSoft { namespace JXSoft {
public class TCPServerEventModel:DataEventModel public class TCPServerModel:DataEventModel
{ {
public override void setLinkState(int linkState) public override void setLinkState(int linkState)
@ -20,5 +20,10 @@ namespace JXSoft {
} }
} }
public class TCPServer {
}
} }

Loading…
Cancel
Save