Browse Source

UDP结构解析

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
f56f9782b0
  1. 323
      Assets/MsgTransmitTools/Example/Scenes/UDPLinkExample.unity
  2. 8
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb.meta
  3. 1504
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab
  4. 7
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab.meta
  5. 8
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script.meta
  6. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientModel.cs
  7. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientModel.cs.meta
  8. 56
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs
  9. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs.meta
  10. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPUtility.cs
  11. 0
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPUtility.cs.meta
  12. 54
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs
  13. 11
      Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs.meta

323
Assets/MsgTransmitTools/Example/Scenes/UDPLinkExample.unity

@ -130,7 +130,6 @@ GameObject: @@ -130,7 +130,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 495072130}
- component: {fileID: 495072131}
m_Layer: 0
m_Name: ScriptManage
m_TagString: Untagged
@ -152,18 +151,6 @@ Transform: @@ -152,18 +151,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &495072131
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 495072129}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 691020c9c00c6734bb9c2fe97ec063f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1048467951
GameObject:
m_ObjectHideFlags: 0
@ -339,3 +326,313 @@ Transform: @@ -339,3 +326,313 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1933351102
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1933351106}
- component: {fileID: 1933351105}
- component: {fileID: 1933351104}
- component: {fileID: 1933351103}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1933351103
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1933351102}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1933351104
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1933351102}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &1933351105
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1933351102}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1933351106
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1933351102}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 4149678946757492273}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &2116950824
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2116950827}
- component: {fileID: 2116950826}
- component: {fileID: 2116950825}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2116950825
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2116950824}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &2116950826
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2116950824}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &2116950827
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2116950824}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &3357100995879704615
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1933351106}
m_Modifications:
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_SizeDelta.x
value: 1280
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_SizeDelta.y
value: 720
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067143300631, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_Name
value: UDPClientInstance
objectReference: {fileID: 0}
- target: {fileID: 1657411067246958876, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067246958876, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067946607568, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1657411067946607568, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 024f7da41de8c5a48a15953f6782dd47, type: 3}
--- !u!224 &4149678946757492273 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1657411067143300630, guid: 024f7da41de8c5a48a15953f6782dd47,
type: 3}
m_PrefabInstance: {fileID: 3357100995879704615}
m_PrefabAsset: {fileID: 0}

8
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb.meta

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

1504
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab

File diff suppressed because it is too large Load Diff

7
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab.meta

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 024f7da41de8c5a48a15953f6782dd47
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script.meta

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

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientModel.cs

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs.meta → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientModel.cs.meta

56
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs

@ -4,6 +4,8 @@ using UnityEngine; @@ -4,6 +4,8 @@ using UnityEngine;
using UnityEngine.Events;
using QFrameworkCP;
using System;
using UnityEngine.UI;
using System.Threading;
namespace JXSoft {
public class UDPMangerArchitecture : Architecture<UDPMangerArchitecture>
@ -25,12 +27,49 @@ namespace JXSoft { @@ -25,12 +27,49 @@ namespace JXSoft {
private string UDPAddress;
private int UDPPort;
private int deviceId;
private UDPUtility udpUtil;
public Transform udpMsgContent;
public GameObject udpMsgItem;
public InputField InputSendMsg;
// Start is called before the first frame update
void Awake()
{
initUDPService();
DontDestroyOnLoad(this);
}
void Start()
{
udpUtil = GetArchitecture().GetUtility<UDPUtility>();
}
// Update is called once per frame
void Update()
{
if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue()))
{
GameObject item = Instantiate(udpMsgItem, udpMsgContent);
item.GetComponentInChildren<Text>().text = udpUtil.receivedData;
this.GetModel<UDPClientModel>().onDataRecived.Invoke(udpUtil.receivedData);
}
if (udpUtil.getTimeOutState() && udpUtil.isOpenUDP)
{
this.SendEvent(new onUDPLinkException(udpUtil.exceptionData));
udpUtil.isOpenUDP = false;
}
}
private void OnDestroy()
{
if (udpUtil.reciveT != null && udpUtil.reciveT.ThreadState == ThreadState.Running)
{
udpUtil.reciveT.Abort();
}
}
public void sendMsg()
{
this.GetUtility<UDPUtility>().sendData(InputSendMsg.text);
}
public void initUDPService()
{
@ -47,7 +86,6 @@ namespace JXSoft { @@ -47,7 +86,6 @@ namespace JXSoft {
if (e.state == UDPLinkState.LinkSucess)
{
Debug.Log("UDP链接成功");
this.GetModel<UDPClientModel>().sendRequest(new LinkUDPRequest(deviceId));
onUDPLinkSuccess.Invoke();
}
if (e.state == UDPLinkState.LinkFaild)
@ -78,20 +116,4 @@ namespace JXSoft { @@ -78,20 +116,4 @@ namespace JXSoft {
}
}
public class LinkUDPRequest : IRequest
{
public string id;
public int type;
public LinkUDPRequest(int id)
{
this.id = id.ToString();
this.type = 1;
}
public string toProtocolData()
{
return JsonUtility.ToJson(this);
}
}
}

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs.meta → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs.meta

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPUtility.cs → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPUtility.cs

0
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPUtility.cs.meta → Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPUtility.cs.meta

54
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs

@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
using System.Threading;
using UnityEngine;
using UnityEngine.UI;
using QFrameworkCP;
namespace JXSoft {
public class UDPPrinter : MonoBehaviour, IController
{
private UDPUtility udpUtil;
public Transform udpMsgContent;
public GameObject udpMsgItem;
public InputField InputSendMsg;
private bool isUDPInit;
// Start is called before the first frame update
void Start()
{
udpUtil = GetArchitecture().GetUtility<UDPUtility>();
}
// Update is called once per frame
void Update()
{
if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue()))
{
GameObject item = Instantiate(udpMsgItem, udpMsgContent);
item.GetComponentInChildren<Text>().text = udpUtil.receivedData;
this.GetModel<UDPClientModel>().onDataRecived.Invoke(udpUtil.receivedData);
}
if (udpUtil.getTimeOutState() && udpUtil.isOpenUDP)
{
this.SendEvent(new onUDPLinkException(udpUtil.exceptionData));
udpUtil.isOpenUDP = false;
}
}
private void OnDestroy()
{
if (udpUtil.reciveT != null && udpUtil.reciveT.ThreadState == ThreadState.Running)
{
udpUtil.reciveT.Abort();
}
}
public void sendMsg()
{
this.GetUtility<UDPUtility>().sendData(InputSendMsg.text);
}
public IArchitecture GetArchitecture()
{
return UDPMangerArchitecture.Interface;
}
}
}

11
Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs.meta

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