|
|
|
@ -13,6 +13,9 @@ namespace JXSoft {
@@ -13,6 +13,9 @@ namespace JXSoft {
|
|
|
|
|
public IOCContainer mCommandContainer = new IOCContainer(); |
|
|
|
|
public UnityStringEvent onDataRecived = new UnityStringEvent(); |
|
|
|
|
public Color printColor = Color.white; |
|
|
|
|
private int linkStatus = 0; |
|
|
|
|
|
|
|
|
|
#region ReceiveFunctions |
|
|
|
|
public void sendResponseCommand<T>(string json) where T : IResponse, new() |
|
|
|
|
{ |
|
|
|
|
//如果找不到对应命令,则添加命令 |
|
|
|
@ -24,7 +27,6 @@ namespace JXSoft {
@@ -24,7 +27,6 @@ namespace JXSoft {
|
|
|
|
|
mCommandContainer.Get<ExcuteResponseCommand<T>>().setJson(json); |
|
|
|
|
this.SendCommand(mCommandContainer.Get<ExcuteResponseCommand<T>>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 开启接收指定数据 |
|
|
|
|
/// </summary> |
|
|
|
@ -41,7 +43,9 @@ namespace JXSoft {
@@ -41,7 +43,9 @@ namespace JXSoft {
|
|
|
|
|
{ |
|
|
|
|
onDataRecived.RemoveListener(sendResponseCommand<T>); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region RequestFunctions |
|
|
|
|
/// <summary> |
|
|
|
|
/// 发送数据 |
|
|
|
|
/// </summary> |
|
|
|
@ -56,6 +60,18 @@ namespace JXSoft {
@@ -56,6 +60,18 @@ namespace JXSoft {
|
|
|
|
|
mCommandContainer.Get<SendRequestCommand<T>>().setRequest(request); |
|
|
|
|
this.SendCommand(mCommandContainer.Get<SendRequestCommand<T>>()); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region LinkStatusManage |
|
|
|
|
public virtual void setLinkStatus(int linkStatus) { |
|
|
|
|
this.linkStatus = linkStatus; |
|
|
|
|
this.SendEvent(new LinkStateChangedEvent(linkStatus)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual int getLinkStatus() { |
|
|
|
|
return linkStatus; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region Command |
|
|
|
@ -180,6 +196,12 @@ namespace JXSoft {
@@ -180,6 +196,12 @@ namespace JXSoft {
|
|
|
|
|
req = req_; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public struct LinkStateChangedEvent { |
|
|
|
|
public int linkState; |
|
|
|
|
public LinkStateChangedEvent(int linkState_) { |
|
|
|
|
linkState = linkState_; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
[Serializable] |
|
|
|
|