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

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

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

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

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

12
Assets/MsgTransmitTools/src/DataEventModel.cs

@ -182,7 +182,6 @@ namespace JXSoft { @@ -182,7 +182,6 @@ namespace JXSoft {
string toProtocolData();
}
public interface ILinkState {
//当前链接状态
int getLinkState();
@ -192,6 +191,8 @@ namespace JXSoft { @@ -192,6 +191,8 @@ namespace JXSoft {
/// <param name="invokeState">目标链接状态</param>
/// <returns>是否成功</returns>
bool transform(ILinkState invokeState);
//DataEventModel getEventModel();
}
#endregion
@ -353,3 +354,12 @@ namespace BaseLinkState @@ -353,3 +354,12 @@ namespace BaseLinkState
#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