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