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