Browse Source

修改了udp相关组件

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

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

@ -1126,7 +1126,18 @@ MonoBehaviour: @@ -1126,7 +1126,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 3357100995107918398}
m_OnClick:
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
GameObject:
m_ObjectHideFlags: 0

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

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

Loading…
Cancel
Save