Browse Source

增加通讯协议切换管理类

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
9a261bfa32
  1. 49
      Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs
  2. 11
      Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs.meta

49
Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QFrameworkCP;
namespace JXSoft {
//通讯协议管理
public class ProtocolSettingsModel : AbstractModel, ICanGetModel
{
protected override void OnInit()
{
}
private ProtocolType protocolType = ProtocolType.NOPROTOCOL;
public DataEventModel getProtocol()
{
switch (protocolType)
{
case (ProtocolType.TCP):
return this.GetModel<TCPEventModel>();
case (ProtocolType.UDP):
return this.GetModel<UDPEventModel>();
default:
return this.GetModel<TCPEventModel>();
}
}
public void setProtocol(ProtocolType type)
{
protocolType = type;
this.SendEvent(new OnProtocolSet(type));
}
}
[SerializeField]
public enum ProtocolType
{
NOPROTOCOL = 0,
TCP = 1,
UDP = 2,
}
public struct OnProtocolSet
{
public ProtocolType type;
public OnProtocolSet(ProtocolType type_)
{
type = type_;
}
}
}

11
Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs.meta

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d9891e78e13faa48b25512ed565fd45
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save