diff --git a/Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity b/Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity index 601e9e3..ec80fd1 100644 --- a/Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity +++ b/Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity @@ -306,8 +306,9 @@ GameObject: m_Component: - component: {fileID: 1020834819} - component: {fileID: 1020834818} + - component: {fileID: 1020834820} m_Layer: 0 - m_Name: GameObject + m_Name: HttpServer m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -341,6 +342,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1020834820 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1020834817} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4936a5bcc164bed44a3060fcf71e91dc, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1822805530 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/MsgTransmitTools/Example/Script.meta b/Assets/MsgTransmitTools/Example/Script.meta new file mode 100644 index 0000000..158b1a7 --- /dev/null +++ b/Assets/MsgTransmitTools/Example/Script.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d3ca353748180184ea5fb965e34c91dc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs b/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs new file mode 100644 index 0000000..25719cf --- /dev/null +++ b/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using JXSoft; + +public class HttpServerExample : MonoBehaviour,IHttpServer +{ + // Start is called before the first frame update + void Start() + { + //接收指定数据后回调 + this.RegisterMessageEvent(e => { + Debug.Log("ip输出:" + e.ip); + }); + //开启接收该类数据,关闭接收可以用this.offReceive(); + this.onReceive(); + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs.meta b/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs.meta new file mode 100644 index 0000000..8a38b6a --- /dev/null +++ b/Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4936a5bcc164bed44a3060fcf71e91dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs index 3a13e36..84b9f45 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs @@ -18,15 +18,11 @@ namespace JXSoft { } public class HttpServerView : MonoBehaviour,IController { + [Header("WebUrl")] public string[] prefixes; // Start is called before the first frame update void Start() { - //Debug.Log(int.Parse("AA",System.Globalization.NumberStyles.HexNumber).ToString()); - this.RegisterMessageEvent(e => { - Debug.Log("收到消息:"+e.ip); - }).UnRegisterWhenGameObjectDestroyed(gameObject); - this.GetModel().onReceive(); startServer(); } @@ -35,10 +31,6 @@ namespace JXSoft { { if (this.GetUtility().httpServer != null && !"".Equals(this.GetUtility().getReceivedValue())) { - /*GameObject item = Instantiate(tcpMsgItem, tcpMsgContent); - item.GetComponentInChildren().text = tcpUtil.receivedData; - this.GetModel().onDataRecived.Invoke(tcpUtil.receivedData); - */ this.GetModel().onDataRecived.Invoke(this.GetUtility().receivedData); } } @@ -57,5 +49,29 @@ namespace JXSoft { return HttpServerArchitecture.Interface; } } + + public interface IHttpServer + { + + } + public static class HttpServerExtention { + public static IUnRegister RegisterMessageEvent(this IHttpServer self, Action onEvent) where TResponse : IResponse + { + return HttpServerArchitecture.Interface.RegisterEvent(e => { + if (e.res.GetType() == typeof(TResponse)) + { + onEvent.Invoke((TResponse)e.res); + } + }); + } + public static void onReceive(this IHttpServer self) where TResponse : IResponse,new() + { + HttpServerArchitecture.Interface.GetModel().onReceive(); + } + public static void offReceive(this IHttpServer self) where TResponse : IResponse, new() + { + HttpServerArchitecture.Interface.GetModel().offReceive(); + } + } } diff --git a/README-EN.md b/README-EN.md new file mode 100644 index 0000000..70c55e1 --- /dev/null +++ b/README-EN.md @@ -0,0 +1,3 @@ +JXSoft使用说明 + +JXsoft是由jkpete编写的一款用于Unity信息管理,信息采集过滤,外接插件,用于信息拦截,网络通讯,本地化存储等。 diff --git a/README-JP.md b/README-JP.md new file mode 100644 index 0000000..70c55e1 --- /dev/null +++ b/README-JP.md @@ -0,0 +1,3 @@ +JXSoft使用说明 + +JXsoft是由jkpete编写的一款用于Unity信息管理,信息采集过滤,外接插件,用于信息拦截,网络通讯,本地化存储等。 diff --git a/README.md b/README.md index 2d5c3d5..2d8325f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ -# JXSoftTools - -金铉Unity插件库 +# JXSoftTools + Unity版本2018.4.32f -目前包含本地化存储功能(根据类名存储读写),TCP客户端监听类型功能 \ No newline at end of file + +JXsoft是由github作者jkpete编写的一款基于Qframework实现的Unity信息管理工具。 + +信息采集过滤,外接插件,用于信息拦截,网络通讯,本地化存储等等信息管理工具。 + +该项目使用了QFramework作为框架基础依赖,该套件也可以脱离QFramework单独使用。 + +QFramework链接:[GitHub - liangxiegame/QFramework: Unity3D System Design Architecture](https://github.com/liangxiegame/QFramework) + +最新日志:增加了HttpServer,可以使用Unity搭建Http服务器了。 + + + +# 消息转换工具MsgTransmitTools + +## 使用方法以TCPClient为例 \ No newline at end of file