Browse Source

添加了打印数据的颜色方案

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
5a5bc6b4fe
  1. 8
      Assets/MsgTransmitTools/Socket.meta
  2. 8
      Assets/MsgTransmitTools/src.meta
  3. 35
      Assets/MsgTransmitTools/src/DataEventModel.cs
  4. 0
      Assets/MsgTransmitTools/src/DataEventModel.cs.meta
  5. 0
      Assets/MsgTransmitTools/src/QFramework.cs
  6. 0
      Assets/MsgTransmitTools/src/QFramework.cs.meta

8
Assets/MsgTransmitTools/Socket.meta

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 25e1e4fdb38352a4d83d79621f265e32
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/MsgTransmitTools/src.meta

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 62f9969ded6e390488fc11942271ab03
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

35
Assets/MsgTransmitTools/TCPClient/Script/Source/DataEventModel.cs → Assets/MsgTransmitTools/src/DataEventModel.cs

@ -11,9 +11,8 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis @@ -11,9 +11,8 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis
{
public IOCContainer mCommandContainer = new IOCContainer();
public UnityStringEvent onDataRecived = new UnityStringEvent();
public void excuteResponseCommand<T>(string json) where T : IResponse, new()
public Color printColor = Color.white;
public void sendResponseCommand<T>(string json) where T : IResponse, new()
{
if (mCommandContainer.Get<ExcuteResponseCommand<T>>() == null)
{
@ -22,13 +21,14 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis @@ -22,13 +21,14 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis
mCommandContainer.Get<ExcuteResponseCommand<T>>().setJson(json);
this.SendCommand(mCommandContainer.Get<ExcuteResponseCommand<T>>());
}
/// <summary>
/// 开启接收指定数据
/// </summary>
/// <typeparam name="T">数据格式类型</typeparam>
public void onReceive<T>() where T : IResponse, new()
{
onDataRecived.AddListener(excuteResponseCommand<T>);
onDataRecived.AddListener(sendResponseCommand<T>);
}
/// <summary>
/// 关闭接收指定数据
@ -36,8 +36,9 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis @@ -36,8 +36,9 @@ public abstract class DataEventModel : AbstractModel, ICanSendCommand, ICanRegis
/// <typeparam name="T">数据格式类型</typeparam>
public void offReceive<T>() where T : IResponse, new()
{
onDataRecived.RemoveListener(excuteResponseCommand<T>);
onDataRecived.RemoveListener(sendResponseCommand<T>);
}
/// <summary>
/// 发送数据
/// </summary>
@ -63,6 +64,7 @@ public class ExcuteResponseCommand<TResponse> : AbstractCommand where TResponse @@ -63,6 +64,7 @@ public class ExcuteResponseCommand<TResponse> : AbstractCommand where TResponse
{
public string json;
private TResponse response;
private Color printColor = Color.white;
public ExcuteResponseCommand(TResponse response)
{
if (this.response == null)
@ -94,6 +96,7 @@ public class SendRequestCommand<TRequest> : AbstractCommand where TRequest : IRe @@ -94,6 +96,7 @@ public class SendRequestCommand<TRequest> : AbstractCommand where TRequest : IRe
}
protected override void OnExecute()
{
//此处需要修改
this.SendEvent(new RequestMsgEvent(request));
}
public void setRequest(TRequest request)
@ -120,22 +123,6 @@ public interface IRequest @@ -120,22 +123,6 @@ public interface IRequest
{
string toJson();
}
//用于标准化通讯方案(具体链接管理,由外部类决定,本接口只提供开启链接跟关闭链接)
public interface IProtocol {
void linkServer();
void closeServer();
}
#endregion
#region Extention
/*
public static class CanGetStateExtention {
public static void GetState<TLinkStatus>(this IProtocol self) {
}
}
*/
#endregion
#region AbstractClass
@ -179,9 +166,11 @@ public struct ResponseMsgEvent @@ -179,9 +166,11 @@ public struct ResponseMsgEvent
res = res_;
}
};
public struct RequestMsgEvent {
public struct RequestMsgEvent
{
public IRequest req;
public RequestMsgEvent(IRequest req_) {
public RequestMsgEvent(IRequest req_)
{
req = req_;
}
}

0
Assets/MsgTransmitTools/TCPClient/Script/Source/DataEventModel.cs.meta → Assets/MsgTransmitTools/src/DataEventModel.cs.meta

0
Assets/MsgTransmitTools/TCPClient/Script/Source/QFramework.cs → Assets/MsgTransmitTools/src/QFramework.cs

0
Assets/MsgTransmitTools/TCPClient/Script/Source/QFramework.cs.meta → Assets/MsgTransmitTools/src/QFramework.cs.meta

Loading…
Cancel
Save