|
|
|
@ -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) |
|
|
|
|
{ |
|
|
|
|
Debug.Log("UDP开始链接"); |
|
|
|
|
this.GetModel<UDPClientModel>().linkServer(); |
|
|
|
|
} |
|
|
|
|
if (e.state == UDPLinkState.LinkSucess) |
|
|
|
|
{ |
|
|
|
|
Debug.Log("UDP链接成功"); |
|
|
|
|
onUDPLinkSuccess.Invoke(); |
|
|
|
|
} |
|
|
|
|
if (e.state == UDPLinkState.LinkFaild) |
|
|
|
|
{ |
|
|
|
|
Debug.Log("UDP连接失败,请联系设备服务管理员"); |
|
|
|
|
onUDPLinkFaild.Invoke(); |
|
|
|
|
} |
|
|
|
|
UDPAddress = "192.168.1.41"; |
|
|
|
|
UDPPort = 52101; |
|
|
|
|
this.RegisterLinkStateEvent((int)UDPLinkState.Linking, () => { |
|
|
|
|
Debug.Log("UDP开始链接"); |
|
|
|
|
this.GetModel<UDPClientModel>().linkServer(); |
|
|
|
|
}); |
|
|
|
|
this.RegisterLinkStateEvent((int)UDPLinkState.LinkSucess, () => |
|
|
|
|
{ |
|
|
|
|
Debug.Log("UDP链接成功"); |
|
|
|
|
onUDPLinkSuccess.Invoke(); |
|
|
|
|
}); |
|
|
|
|
this.RegisterLinkStateEvent((int)UDPLinkState.LinkFaild, () => |
|
|
|
|
{ |
|
|
|
|
Debug.Log("UDP连接失败,请联系设备服务管理员"); |
|
|
|
|
onUDPLinkFaild.Invoke(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.GetModel<UDPClientModel>().setLinkState((int)UDPLinkState.NoIp); |
|
|
|
|
this.GetModel<UDPClientModel>().setIP(UDPAddress, UDPPort); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|