Updated NetDebug, changed List To ConcurrentQueue

This commit is contained in:
Sofia 2020-08-10 23:18:37 +03:00
parent 83b09442d2
commit 1962212ec0
11 changed files with 617 additions and 7 deletions

View File

@ -0,0 +1,400 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2333684850761985145
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2333684850761985146}
- component: {fileID: 2333684850761985124}
- component: {fileID: 2333684850761985147}
m_Layer: 5
m_Name: ReceivedText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2333684850761985146
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850761985145}
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: 2333684851214627333}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 150, y: 0}
m_SizeDelta: {x: 300, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2333684850761985124
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850761985145}
m_CullTransparentMesh: 0
--- !u!114 &2333684850761985147
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850761985145}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: c780c2251e690fb498319dc38127843c, type: 2}
m_sharedMaterial: {fileID: 4067991147299334843, guid: c780c2251e690fb498319dc38127843c, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 12
m_fontSizeBase: 12
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2333684850843635560
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2333684850843635561}
- component: {fileID: 2333684850843635562}
m_Layer: 5
m_Name: NetDebug
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2333684850843635561
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850843635560}
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:
- {fileID: 2333684851214627333}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2333684850843635562
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850843635560}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48e2ed0c59f482249828cded7257d545, type: 3}
m_Name:
m_EditorClassIdentifier:
BackgroundPanel: {fileID: 2333684851214627333}
ReceivedText: {fileID: 2333684850761985147}
SentText: {fileID: 2333684850864540530}
UpdateInterval: 5
--- !u!1 &2333684850864540528
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2333684850864540529}
- component: {fileID: 2333684850864540531}
- component: {fileID: 2333684850864540530}
m_Layer: 5
m_Name: SentText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2333684850864540529
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850864540528}
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: 2333684851214627333}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 450, y: 0}
m_SizeDelta: {x: 300, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2333684850864540531
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850864540528}
m_CullTransparentMesh: 0
--- !u!114 &2333684850864540530
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684850864540528}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: c780c2251e690fb498319dc38127843c, type: 2}
m_sharedMaterial: {fileID: 4067991147299334843, guid: c780c2251e690fb498319dc38127843c, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 12
m_fontSizeBase: 12
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2333684851214627332
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2333684851214627333}
- component: {fileID: 2333684851214627335}
- component: {fileID: 2333684851214627334}
m_Layer: 5
m_Name: Background Panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2333684851214627333
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684851214627332}
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:
- {fileID: 2333684850761985146}
- {fileID: 2333684850864540529}
m_Father: {fileID: 2333684850843635561}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2333684851214627335
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684851214627332}
m_CullTransparentMesh: 0
--- !u!114 &2333684851214627334
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333684851214627332}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.20392157}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1

View File

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

View File

@ -247,6 +247,11 @@ Light:
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!224 &187323709 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
m_PrefabInstance: {fileID: 2333684850756983380}
m_PrefabAsset: {fileID: 0}
--- !u!1 &187747572
GameObject:
m_ObjectHideFlags: 0
@ -2569,6 +2574,7 @@ RectTransform:
- {fileID: 360197057}
- {fileID: 267525579}
- {fileID: 816236546}
- {fileID: 187323709}
m_Father: {fileID: 187747573}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -3759,3 +3765,104 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1a03b85f19189674187c9966f5f557e3, type: 3}
--- !u!1001 &2333684850756983380
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1734890299}
m_Modifications:
- target: {fileID: 2333684850843635560, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_Name
value: NetDebug
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2333684850843635561, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2333684851214627332, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a58c5106b49e7e14a8c5f2e7f8410513, type: 3}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4737d69f6976d7140b2c8dc50be50462
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,50 @@
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;
using NeonTea.Quakeball.Networking;
using System;
public class NetDebugScreen : MonoBehaviour {
public RectTransform BackgroundPanel;
public TMP_Text ReceivedText;
public TMP_Text SentText;
public float UpdateInterval = 5f;
private InputAction ToggleNetDebug;
private float LastUpdate;
private bool IsOpen;
private void Start() {
ToggleNetDebug = new InputAction("Toggle Net Debug", binding: "<Keyboard>/F3");
ToggleNetDebug.Enable();
ToggleNetDebug.performed += _ => {
IsOpen = !IsOpen;
BackgroundPanel.gameObject.SetActive(IsOpen);
};
}
private void Update() {
bool NetworkingAvailable = Net.Singleton.Instance != null && Net.Singleton.Instance.Peer.Running;
if (IsOpen && !NetworkingAvailable) {
ReceivedText.text = "No networking data to show";
SentText.text = "";
} else if (IsOpen && NetworkingAvailable) {
var Peer = Net.Singleton.Instance.Peer;
if (Time.time - LastUpdate > UpdateInterval) {
LastUpdate = Time.time;
float ToSeconds = 1f / (Peer.TrafficDataInterval / 1000f);
string received = $"Total Bytes Receivd: {Peer.TrafficReceived * ToSeconds} B/s\nReceived by packet:";
foreach (Type t in Peer.TrafficReceivedByPacket.Keys) {
received += $"\n{t.Name} - {Peer.TrafficReceivedByPacket[t] * ToSeconds} B/s";
}
ReceivedText.text = received;
string sent = $"Total Bytes Sent: {Net.Singleton.Instance.Peer.TrafficSent * ToSeconds} B/s\nSent by packet:";
foreach (Type t in Peer.TrafficSentByPacket.Keys) {
sent += $"\n{t.Name} - {Peer.TrafficSentByPacket[t] * ToSeconds} B/s";
}
SentText.text = sent;
}
}
}
}

View File

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

View File

@ -54,6 +54,7 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
} else if (connection.Status == ConnectionStatus.Ready) {
buffer.Write((byte)PacketStage.Ready);
buffer.Write(connection.Internal.LatestInwardReliable);
buffer.Write(connection.Internal.CurrentFirstPacket);
}
return buffer;
}

View File

@ -57,6 +57,9 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
/// <summary>Last unreliable Packet ID we've received from the connection</summary>
public int LatestInwardUnreliable;
/// <summary>The id of the first packet in the queue to be sent</summary>
public int CurrentFirstPacket;
/// <summary>Reliable Packet ID counter for packets we're sending them</summary>
public int ReliablePacketIDCounter;
/// <summary>Unreliable Packet ID counter for packets we're sending them</summary>

View File

@ -4,6 +4,7 @@ using System.Net;
using System.Threading;
using System;
using NeonTea.Quakeball.TeaNet.Packets;
using UnityEngine;
namespace NeonTea.Quakeball.TeaNet.Peers {
/// <summary>Manages connections for Peer, sends them keepalives and sends and handles incoming messages.</summary>
@ -11,7 +12,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
private ulong ConnectionCounter;
private Dictionary<ulong, Connection> Connections = new Dictionary<ulong, Connection>();
private Dictionary<IPEndPoint, ulong> IPtoID = new Dictionary<IPEndPoint, ulong>();
private Dictionary<ulong, List<Packet>> PacketQueue = new Dictionary<ulong, List<Packet>>();
private Dictionary<ulong, ConcurrentQueue<Packet>> PacketQueue = new Dictionary<ulong, ConcurrentQueue<Packet>>();
private Peer Peer;
public Dictionary<ulong, Queue<ProtocolAction>> ProtocolActionQueues = new Dictionary<ulong, Queue<ProtocolAction>>();
@ -80,7 +81,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
}
p = p.ShallowCopy();
p.PacketId = Connections[uid].Internal.ReliablePacketIDCounter++;
PacketQueue[uid].Add(p);
PacketQueue[uid].Enqueue(p);
}
/// <summary>Send the current packet queue instantly.</summary>
@ -157,7 +158,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
conn.uid = ConnectionCounter++;
Connections.Add(conn.uid, conn);
IPtoID.Add(conn.Endpoint, conn.uid);
PacketQueue.Add(conn.uid, new List<Packet>());
PacketQueue.Add(conn.uid, new ConcurrentQueue<Packet>());
}
private void RemoveConnection(Connection conn) {
@ -238,14 +239,28 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
}
conn.Internal.LatestOutwardReliable = buffer.ReadInt();
int FirstPacketId = buffer.ReadInt();
List<Packet> list = PacketQueue[conn.uid];
list.RemoveAll(p => p.PacketId <= conn.Internal.LatestOutwardReliable);
PacketQueue[conn.uid] = list;
ConcurrentQueue<Packet> queue = PacketQueue[conn.uid];
Packet peeked;
while (queue.TryPeek(out peeked)) {
if (peeked.PacketId <= conn.Internal.LatestOutwardReliable) {
Packet discarded;
queue.TryDequeue(out discarded);
continue;
}
conn.Internal.CurrentFirstPacket = peeked.PacketId;
break;
}
PacketQueue[conn.uid] = queue;
int PacketAmount = buffer.ReadInt();
for (int i = 0; i < PacketAmount; i++) {
Packet p = buffer.ReadPacket(protocol);
//p.PacketId = FirstPacketId + i;
if (i == 0 && p.PacketId == FirstPacketId) {
//Debug.Log("Matched!");
}
if (p.PacketIsReliable) {
if (p.PacketId > conn.Internal.LatestInwardReliable) {
conn.Internal.LatestInwardReliable = p.PacketId;

View File

@ -179,7 +179,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
ConnectionManager.ReceivedByPacket[t] = 0;
}
foreach (Type t in ConnectionManager.SentByPacket.Keys) {
ConnectionManager.ReceivedByPacket[t] = 0;
ConnectionManager.SentByPacket[t] = 0;
}
}
}