Browse Source

修改了udp相关组件

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
b5d92727b5
  1. 13
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab
  2. 46
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs

13
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab

@ -1126,7 +1126,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 3357100995107918398} m_TargetGraphic: {fileID: 3357100995107918398}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 1657411067143300629}
m_MethodName: sendMsg
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &3357100995867598124 --- !u!1 &3357100995867598124
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

46
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs

@ -26,21 +26,15 @@ namespace JXSoft {
private string UDPAddress; private string UDPAddress;
private int UDPPort; private int UDPPort;
private int deviceId;
private UDPUtility udpUtil; private UDPUtility udpUtil;
public Transform udpMsgContent; public Transform udpMsgContent;
public GameObject udpMsgItem; public GameObject udpMsgItem;
public InputField InputSendMsg; public InputField InputSendMsg;
// Start is called before the first frame update
void Awake()
{
initUDPService();
DontDestroyOnLoad(this);
}
void Start() void Start()
{ {
udpUtil = GetArchitecture().GetUtility<UDPUtility>(); udpUtil = GetArchitecture().GetUtility<UDPUtility>();
initUDPService();
} }
// Update is called once per frame // Update is called once per frame
@ -73,29 +67,23 @@ namespace JXSoft {
public void initUDPService() public void initUDPService()
{ {
UDPAddress = "127.0.0.1"; UDPAddress = "192.168.1.41";
UDPPort = 20000; UDPPort = 52101;
deviceId = 1; this.RegisterLinkStateEvent((int)UDPLinkState.Linking, () => {
Debug.Log("UDP开始链接");
GetArchitecture().RegisterEvent<UDPStateChangedEvent>(e => { this.GetModel<UDPClientModel>().linkServer();
if (e.state == UDPLinkState.Linking) });
{ this.RegisterLinkStateEvent((int)UDPLinkState.LinkSucess, () =>
Debug.Log("UDP开始链接"); {
this.GetModel<UDPClientModel>().linkServer(); Debug.Log("UDP链接成功");
} onUDPLinkSuccess.Invoke();
if (e.state == UDPLinkState.LinkSucess) });
{ this.RegisterLinkStateEvent((int)UDPLinkState.LinkFaild, () =>
Debug.Log("UDP链接成功"); {
onUDPLinkSuccess.Invoke(); Debug.Log("UDP连接失败,请联系设备服务管理员");
} onUDPLinkFaild.Invoke();
if (e.state == UDPLinkState.LinkFaild)
{
Debug.Log("UDP连接失败,请联系设备服务管理员");
onUDPLinkFaild.Invoke();
}
}); });
this.GetModel<UDPClientModel>().setLinkState((int)UDPLinkState.NoIp);
this.GetModel<UDPClientModel>().setIP(UDPAddress, UDPPort); this.GetModel<UDPClientModel>().setIP(UDPAddress, UDPPort);
} }

Loading…
Cancel
Save