Browse Source

区分外部数据结构包

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
2141b9fee5
  1. 7
      Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs
  2. 6
      Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs
  3. 4
      Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs
  4. 12
      Assets/MsgTransmitTools/src/DataEventModel.cs

7
Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs

@ -3,9 +3,10 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using LitJson; using LitJson;
using System; using System;
using JXSoft;
namespace JXSoft { namespace DYData {
public struct BluetoothGateway:IResponse public struct BluetoothGatewayData:IResponse
{ {
/// <summary> /// <summary>
/// ///
@ -57,7 +58,7 @@ namespace JXSoft {
{ {
try try
{ {
BluetoothGateway blg = JsonMapper.ToObject<BluetoothGateway>(protocolData); BluetoothGatewayData blg = JsonMapper.ToObject<BluetoothGatewayData>(protocolData);
this.v = blg.v; this.v = blg.v;
this.time = blg.time; this.time = blg.time;
this.mid = blg.mid; this.mid = blg.mid;

6
Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs

@ -11,7 +11,7 @@ using System.IO;
namespace JXSoft { namespace JXSoft {
public class HttpServerModel : DataEventModel public class HttpServerModel : DataEventModel
{ {
public ServerState httpServerState = ServerState.Close;
protected override void OnInit() protected override void OnInit()
{ {
@ -19,12 +19,12 @@ namespace JXSoft {
public override void setLinkState(int linkState) public override void setLinkState(int linkState)
{ {
this.httpServerState = (ServerState)linkState;
} }
public override int getLinkState() public override int getLinkState()
{ {
return 0; return (int)httpServerState;
} }
} }
public enum ServerState public enum ServerState

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

@ -24,10 +24,10 @@ namespace JXSoft {
void Start() void Start()
{ {
this.httpServer = this.GetUtility<HttpServerUtility>(); this.httpServer = this.GetUtility<HttpServerUtility>();
this.RegisterMessageEvent<BluetoothGateway>(e => { this.RegisterMessageEvent<DYData.BluetoothGatewayData>(e => {
Debug.Log("收到消息:"+e.ip); Debug.Log("收到消息:"+e.ip);
}).UnRegisterWhenGameObjectDestroyed(gameObject); }).UnRegisterWhenGameObjectDestroyed(gameObject);
this.GetModel<HttpServerModel>().onReceive<BluetoothGateway>(); this.GetModel<HttpServerModel>().onReceive<DYData.BluetoothGatewayData>();
} }
// Update is called once per frame // Update is called once per frame

12
Assets/MsgTransmitTools/src/DataEventModel.cs

@ -182,7 +182,6 @@ namespace JXSoft {
string toProtocolData(); string toProtocolData();
} }
public interface ILinkState { public interface ILinkState {
//当前链接状态 //当前链接状态
int getLinkState(); int getLinkState();
@ -192,6 +191,8 @@ namespace JXSoft {
/// <param name="invokeState">目标链接状态</param> /// <param name="invokeState">目标链接状态</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
bool transform(ILinkState invokeState); bool transform(ILinkState invokeState);
//DataEventModel getEventModel();
} }
#endregion #endregion
@ -352,4 +353,13 @@ namespace BaseLinkState
#endregion #endregion
}
/// <summary>
/// this Package improved a base example of server open & close
/// you can also create class implements ILinkState.
/// </summary>
namespace BaseServerState {
} }
Loading…
Cancel
Save