Browse Source

添加相关扩展方法,部分文档创建

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
4098e7b191
  1. 15
      Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity
  2. 8
      Assets/MsgTransmitTools/Example/Script.meta
  3. 24
      Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs
  4. 11
      Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs.meta
  5. 34
      Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs
  6. 3
      README-EN.md
  7. 3
      README-JP.md
  8. 22
      README.md

15
Assets/MsgTransmitTools/Example/Scenes/HttpServerExample.unity

@ -306,8 +306,9 @@ GameObject: @@ -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: @@ -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

8
Assets/MsgTransmitTools/Example/Script.meta

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

24
Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs

@ -0,0 +1,24 @@ @@ -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<DYData.BluetoothGatewayData>(e => {
Debug.Log("ip输出:" + e.ip);
});
//开启接收该类数据,关闭接收可以用this.offReceive<DYData.BluetoothGatewayData>();
this.onReceive<DYData.BluetoothGatewayData>();
}
// Update is called once per frame
void Update()
{
}
}

11
Assets/MsgTransmitTools/Example/Script/HttpServerExample.cs.meta

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4936a5bcc164bed44a3060fcf71e91dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

34
Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs

@ -18,15 +18,11 @@ namespace JXSoft { @@ -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<DYData.BluetoothGatewayData>(e => {
Debug.Log("收到消息:"+e.ip);
}).UnRegisterWhenGameObjectDestroyed(gameObject);
this.GetModel<HttpServerModel>().onReceive<DYData.BluetoothGatewayData>();
startServer();
}
@ -35,10 +31,6 @@ namespace JXSoft { @@ -35,10 +31,6 @@ namespace JXSoft {
{
if (this.GetUtility<HttpServerUtility>().httpServer != null && !"".Equals(this.GetUtility<HttpServerUtility>().getReceivedValue()))
{
/*GameObject item = Instantiate(tcpMsgItem, tcpMsgContent);
item.GetComponentInChildren<Text>().text = tcpUtil.receivedData;
this.GetModel<TCPClientModel>().onDataRecived.Invoke(tcpUtil.receivedData);
*/
this.GetModel<HttpServerModel>().onDataRecived.Invoke(this.GetUtility<HttpServerUtility>().receivedData);
}
}
@ -57,5 +49,29 @@ namespace JXSoft { @@ -57,5 +49,29 @@ namespace JXSoft {
return HttpServerArchitecture.Interface;
}
}
public interface IHttpServer
{
}
public static class HttpServerExtention {
public static IUnRegister RegisterMessageEvent<TResponse>(this IHttpServer self, Action<TResponse> onEvent) where TResponse : IResponse
{
return HttpServerArchitecture.Interface.RegisterEvent<ResponseMsgEvent>(e => {
if (e.res.GetType() == typeof(TResponse))
{
onEvent.Invoke((TResponse)e.res);
}
});
}
public static void onReceive<TResponse>(this IHttpServer self) where TResponse : IResponse,new()
{
HttpServerArchitecture.Interface.GetModel<HttpServerModel>().onReceive<TResponse>();
}
public static void offReceive<TResponse>(this IHttpServer self) where TResponse : IResponse, new()
{
HttpServerArchitecture.Interface.GetModel<HttpServerModel>().offReceive<TResponse>();
}
}
}

3
README-EN.md

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
JXSoft使用说明
JXsoft是由jkpete编写的一款用于Unity信息管理,信息采集过滤,外接插件,用于信息拦截,网络通讯,本地化存储等。

3
README-JP.md

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
JXSoft使用说明
JXsoft是由jkpete编写的一款用于Unity信息管理,信息采集过滤,外接插件,用于信息拦截,网络通讯,本地化存储等。

22
README.md

@ -1,5 +1,19 @@ @@ -1,5 +1,19 @@
# JXSoftTools
金铉Unity插件库
# JXSoftTools
Unity版本2018.4.32f
目前包含本地化存储功能(根据类名存储读写),TCP客户端监听类型功能
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为例
Loading…
Cancel
Save