Skip to content

Commit 5ca26bc

Browse files
committed
Added XML comments and cleaned up minor things
1 parent 2946168 commit 5ca26bc

File tree

12 files changed

+173
-31
lines changed

12 files changed

+173
-31
lines changed

MLAPI/Data/FixedQueue.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public sealed class FixedQueue<T>
1717
/// </summary>
1818
public int Count { get => queueCount; }
1919

20+
/// <summary>
21+
/// Gets the element at a given virtual index
22+
/// </summary>
23+
/// <param name="index">The virtual index to get the item from</param>
24+
/// <returns>The element at the virtual index</returns>
2025
public T this[int index]
2126
{
2227
get
@@ -66,8 +71,8 @@ public T Dequeue()
6671
/// <summary>
6772
/// Gets the element at a given virtual index
6873
/// </summary>
69-
/// <param name="index"></param>
70-
/// <returns></returns>
74+
/// <param name="index">The virtual index to get the item from</param>
75+
/// <returns>The element at the virtual index</returns>
7176
public T ElementAt(int index) => queue[(queueStart + index) % queue.Length];
7277
}
7378
}

MLAPI/Data/HashCode.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace MLAPI.Data
44
{
5+
/// <summary>
6+
/// Provides extension methods for getting hashes
7+
/// </summary>
58
public static class HashCode
69
{
710
private const uint FNV_offset_basis32 = 2166136261;
@@ -87,7 +90,7 @@ public static ulong GetStableHash64(this string txt)
8790
/// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
8891
/// </summary>
8992
/// <returns>The stable hash32.</returns>
90-
/// <param name="txt">Text.</param>
93+
/// <param name="bytes">Text.</param>
9194
public static ushort GetStableHash16(this byte[] bytes)
9295
{
9396
uint hash32 = bytes.GetStableHash32();
@@ -104,7 +107,7 @@ public static ushort GetStableHash16(this byte[] bytes)
104107
/// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
105108
/// </summary>
106109
/// <returns>The stable hash32.</returns>
107-
/// <param name="txt">Text.</param>
110+
/// <param name="bytes">Text.</param>
108111
public static uint GetStableHash32(this byte[] bytes)
109112
{
110113
unchecked
@@ -129,7 +132,7 @@ public static uint GetStableHash32(this byte[] bytes)
129132
/// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
130133
/// </summary>
131134
/// <returns>The stable hash32.</returns>
132-
/// <param name="txt">Text.</param>
135+
/// <param name="bytes">Text.</param>
133136
public static ulong GetStableHash64(this byte[] bytes)
134137
{
135138
unchecked

MLAPI/Data/NetworkConfig.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ public class NetworkConfig
154154
/// </summary>
155155
public AttributeMessageMode AttributeMessageMode = AttributeMessageMode.Disabled;
156156

157+
/// <summary>
158+
/// Returns a base64 encoded version of the config
159+
/// </summary>
160+
/// <returns></returns>
157161
public string ToBase64()
158162
{
159163
NetworkConfig config = this;
@@ -212,7 +216,12 @@ public string ToBase64()
212216
return Convert.ToBase64String(writer.Finalize());
213217
}
214218
}
215-
219+
220+
/// <summary>
221+
/// Sets the NetworkConfig data with that from a base64 encoded version
222+
/// </summary>
223+
/// <param name="base64">The base64 encoded version</param>
224+
/// <param name="createDummyObject">Wheter or not to create dummy objects for NetworkedPrefabs</param>
216225
public void FromBase64(string base64, bool createDummyObject = false)
217226
{
218227
NetworkConfig config = this;

MLAPI/Data/NetworkProfiler/NetworkProfiler.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@
44

55
namespace MLAPI.Data.NetworkProfiler
66
{
7+
/// <summary>
8+
/// NetworkProfiler for profiling network traffic
9+
/// </summary>
710
public static class NetworkProfiler
811
{
12+
/// <summary>
13+
/// The ticks that has been recorded
14+
/// </summary>
915
public static FixedQueue<ProfilerTick> Ticks { get; private set; }
16+
/// <summary>
17+
/// Wheter or not the profiler is recording data
18+
/// </summary>
1019
public static bool isRunning { get; private set; }
1120
private static int tickHistory = 1024;
1221
private static int EventIdCounter = 0;
1322
private static ProfilerTick CurrentTick;
1423

24+
/// <summary>
25+
/// Starts recording data for the Profiler
26+
/// </summary>
27+
/// <param name="historyLength">The amount of ticks to keep in memory</param>
1528
public static void Start(int historyLength)
1629
{
1730
if (isRunning)
@@ -23,13 +36,21 @@ public static void Start(int historyLength)
2336
isRunning = true;
2437
}
2538

39+
/// <summary>
40+
/// Stops recording data
41+
/// </summary>
2642
public static void Stop()
2743
{
2844
Ticks = null; //leave to GC
2945
CurrentTick = null; //leave to GC
3046
isRunning = false;
3147
}
3248

49+
/// <summary>
50+
/// Stops recording data and fills the buffer with the recorded ticks and returns the length;
51+
/// </summary>
52+
/// <param name="tickBuffer">The buffer to fill with the ticks</param>
53+
/// <returns>The number of ticks recorded</returns>
3354
public static int Stop(ref ProfilerTick[] tickBuffer)
3455
{
3556
if (!isRunning)
@@ -44,6 +65,11 @@ public static int Stop(ref ProfilerTick[] tickBuffer)
4465
return iteration;
4566
}
4667

68+
/// <summary>
69+
/// Stops recording data and fills the buffer with the recorded ticks and returns the length;
70+
/// </summary>
71+
/// <param name="tickBuffer">The buffer to fill with the ticks</param>
72+
/// <returns>The number of ticks recorded</returns>
4773
public static int Stop(ref List<ProfilerTick> tickBuffer)
4874
{
4975
if (!isRunning)

MLAPI/Data/NetworkProfiler/ProfilerTickData.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@
33

44
namespace MLAPI.Data.NetworkProfiler
55
{
6+
/// <summary>
7+
/// The type of Tick
8+
/// </summary>
69
public enum TickType
710
{
11+
/// <summary>
12+
/// Event tick. During EventTick SyncedVars are flushed etc
13+
/// </summary>
814
Event,
15+
/// <summary>
16+
/// Receive tick. During ReceiveTick data is received from the transport
17+
/// </summary>
918
Receive,
19+
/// <summary>
20+
/// Send tick. During Send data is sent from Transport queue
21+
/// </summary>
1022
Send
1123
}
24+
/// <summary>
25+
/// A tick in used for the Profiler
26+
/// </summary>
1227
public class ProfilerTick
1328
{
29+
/// <summary>
30+
/// The events that occured during this tick
31+
/// </summary>
1432
[BinaryIgnore]
1533
public readonly List<TickEvent> Events = new List<TickEvent>();
1634
private TickEvent[] events;
@@ -54,9 +72,21 @@ internal void StartEvent(TickType type, uint bytes, string channelName, string m
5472
Events.Add(tickEvent);
5573
}
5674

75+
/// <summary>
76+
/// The type of tick
77+
/// </summary>
5778
public TickType Type;
79+
/// <summary>
80+
/// The frame the tick executed on
81+
/// </summary>
5882
public int Frame;
83+
/// <summary>
84+
/// The id of the tick
85+
/// </summary>
5986
public int EventId;
87+
/// <summary>
88+
/// The amount of bytes that were sent and / or recieved during this tick
89+
/// </summary>
6090
public uint Bytes
6191
{
6292
get
@@ -68,12 +98,30 @@ public uint Bytes
6898
}
6999
}
70100

101+
/// <summary>
102+
/// A event that can occur during a Event
103+
/// </summary>
71104
public class TickEvent
72105
{
106+
/// <summary>
107+
/// The type of evenmt
108+
/// </summary>
73109
public TickType EventType;
110+
/// <summary>
111+
/// The amount of bytes sent or received
112+
/// </summary>
74113
public uint Bytes;
114+
/// <summary>
115+
/// The name of the channel
116+
/// </summary>
75117
public string ChannelName;
118+
/// <summary>
119+
/// The message type
120+
/// </summary>
76121
public string MessageType;
122+
/// <summary>
123+
/// Wheter or not the event is closed
124+
/// </summary>
77125
public bool Closed;
78126
}
79127
}

MLAPI/Data/Transports/UNET/RelayTransport.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using MLAPI.MonoBehaviours.Core;
1+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2+
using MLAPI.MonoBehaviours.Core;
23
using System;
34
using System.Collections.Generic;
45
using System.Net;
@@ -199,10 +200,7 @@ public static bool QueueMessageForSending(int hostId, int connectionId, int chan
199200
return NetworkTransport.QueueMessageForSending(hostId, relayConnectionId, channelId, buffer, size, out error);
200201
}
201202

202-
public static bool SendQueuedMessages(int hostId, int connectionId, out byte error)
203-
{
204-
return NetworkTransport.SendQueuedMessages(hostId, relayConnectionId, out error);
205-
}
203+
public static bool SendQueuedMessages(int hostId, int connectionId, out byte error) => NetworkTransport.SendQueuedMessages(hostId, relayConnectionId, out error);
206204

207205
public static NetworkEventType ReceiveFromHost(int hostId, out int connectionId, out int channelId, byte[] buffer, int bufferSize, out int receivedSize, out byte error)
208206
{
@@ -330,3 +328,4 @@ public InvalidConfigException() { }
330328
public InvalidConfigException(string issue) : base(issue) { }
331329
}
332330
}
331+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

0 commit comments

Comments
 (0)