Skip to content

Commit a02bb8d

Browse files
committed
Added XML comments
1 parent 5e1a063 commit a02bb8d

File tree

12 files changed

+307
-68
lines changed

12 files changed

+307
-68
lines changed

MLAPI/Data/Transports/ChannelType.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,53 @@
11
namespace MLAPI.Data
22
{
3+
/// <summary>
4+
/// Delivery methods
5+
/// </summary>
36
public enum ChannelType
47
{
8+
/// <summary>
9+
/// Unreliable message
10+
/// </summary>
511
Unreliable,
12+
/// <summary>
13+
/// Unreliable with fragmentation support
14+
/// </summary>
615
UnreliableFragmented,
16+
/// <summary>
17+
/// Unreliable with sequencing
18+
/// </summary>
719
UnreliableSequenced,
20+
/// <summary>
21+
/// Reliable message
22+
/// </summary>
823
Reliable,
24+
/// <summary>
25+
/// Reliable with fragmentation support
26+
/// </summary>
927
ReliableFragmented,
28+
/// <summary>
29+
/// Reliable message where messages are guaranteed to be in the right order
30+
/// </summary>
1031
ReliableSequenced,
32+
/// <summary>
33+
/// A unreliable state update message
34+
/// </summary>
1135
StateUpdate,
36+
/// <summary>
37+
/// A reliable state update message
38+
/// </summary>
1239
ReliableStateUpdate,
40+
/// <summary>
41+
/// A reliable message with high priority
42+
/// </summary>
1343
AllCostDelivery,
44+
/// <summary>
45+
/// Unreliable message with fragmentation where older messages are dropped
46+
/// </summary>
1447
UnreliableFragmentedSequenced,
48+
/// <summary>
49+
/// A reliable message with guaranteed order with fragmentation support
50+
/// </summary>
1551
ReliableFragmentedSequenced
1652
}
1753
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
namespace MLAPI.Data.Transports
22
{
3+
/// <summary>
4+
/// Supported built in transport
5+
/// </summary>
36
public enum DefaultTransport
47
{
8+
/// <summary>
9+
/// Unity's UNET transport
10+
/// </summary>
511
UNET,
12+
/// <summary>
13+
/// LiteNetLib transport
14+
/// </summary>
615
LiteNetLib,
16+
/// <summary>
17+
/// A custom transport
18+
/// </summary>
719
Custom
820
}
921
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,110 @@
11
namespace MLAPI.Data
22
{
3+
/// <summary>
4+
/// A UDP transport
5+
/// </summary>
36
public interface IUDPTransport
47
{
8+
/// <summary>
9+
/// The channelType the Internal library will use
10+
/// </summary>
511
ChannelType InternalChannel { get; }
12+
/// <summary>
13+
/// The clientId to use when you want to send to the server from client
14+
/// </summary>
615
uint ServerNetId { get; }
16+
/// <summary>
17+
/// A dummy clientId to represent the host client
18+
/// </summary>
719
uint HostDummyId { get; }
20+
/// <summary>
21+
/// A invalid clientId to represent a clientId of server
22+
/// </summary>
823
uint InvalidDummyId { get; }
24+
/// <summary>
25+
/// Queues a message for sending.
26+
/// </summary>
27+
/// <param name="clientId">The clientId to send to</param>
28+
/// <param name="dataBuffer">The buffer to read from</param>
29+
/// <param name="dataSize">The amount of data to send from the buffer</param>
30+
/// <param name="channelId">The channelId to send on</param>
31+
/// <param name="skipQueue">Wheter or not Send will have to be called for this message to be sent</param>
32+
/// <param name="error">Error byte. Does nothhing</param>
933
void QueueMessageForSending(uint clientId, ref byte[] dataBuffer, int dataSize, int channelId, bool skipQueue, out byte error);
34+
/// <summary>
35+
/// Sends queued messages for a specific clientId
36+
/// </summary>
37+
/// <param name="clientId">The clientId to send</param>
38+
/// <param name="error">Error byte. Does nothhing</param>
1039
void SendQueue(uint clientId, out byte error);
40+
/// <summary>
41+
/// Polls for incomming events
42+
/// </summary>
43+
/// <param name="clientId">The clientId this event is for</param>
44+
/// <param name="channelId">The channelId this message comes from</param>
45+
/// <param name="data">The data buffer, if any</param>
46+
/// <param name="bufferSize">The size of the buffer</param>
47+
/// <param name="receivedSize">The amount of bytes we received</param>
48+
/// <param name="error">Error byte. Does nothhing</param>
49+
/// <returns>Returns the event type</returns>
1150
NetEventType PollReceive(out uint clientId, out int channelId, ref byte[] data, int bufferSize, out int receivedSize, out byte error);
51+
/// <summary>
52+
/// Adds a channel with a specific type
53+
/// </summary>
54+
/// <param name="type">The channelType</param>
55+
/// <param name="settings">The settings object used by the transport</param>
56+
/// <returns>Returns a unique id for the channel</returns>
1257
int AddChannel(ChannelType type, object settings);
58+
/// <summary>
59+
/// Connects client to server
60+
/// </summary>
61+
/// <param name="address">The address to connect to</param>
62+
/// <param name="port">The port to connect to</param>
63+
/// <param name="settings">The settings object to use for the transport</param>
64+
/// <param name="error">Error byte. Does nothhing</param>
1365
void Connect(string address, int port, object settings, out byte error);
66+
/// <summary>
67+
/// Starts to listen for incomming clients.
68+
/// </summary>
69+
/// <param name="settings">The settings object for the transport</param>
1470
void RegisterServerListenSocket(object settings);
71+
/// <summary>
72+
/// Disconnects a client from the server
73+
/// </summary>
74+
/// <param name="clientId">The clientId to disconnect</param>
1575
void DisconnectClient(uint clientId);
76+
/// <summary>
77+
/// Disconnects client from the server
78+
/// </summary>
1679
void DisconnectFromServer();
80+
/// <summary>
81+
/// Gets the round trip time for a specific client
82+
/// </summary>
83+
/// <param name="clientId">The clientId to get the rtt from</param>
84+
/// <param name="error">Error byte. Does nothhing</param>
85+
/// <returns>Returns the event type</returns>
1786
int GetCurrentRTT(uint clientId, out byte error);
87+
/// <summary>
88+
/// Gets a delay in miliseconds based on a timestamp
89+
/// </summary>
90+
/// <param name="clientId">The clientId to get the delay for</param>
91+
/// <param name="remoteTimestamp">The timestamp</param>
92+
/// <param name="error">Error byte. Does nothhing</param>
93+
/// <returns>Returns the delay in miliseconds</returns>
1894
int GetRemoteDelayTimeMS(uint clientId, int remoteTimestamp, out byte error);
95+
/// <summary>
96+
/// Gets a timestamp to be used for calculating latency
97+
/// </summary>
98+
/// <returns>The timestamp</returns>
1999
int GetNetworkTimestamp();
100+
/// <summary>
101+
/// Inits the transport and returns a settings object to be used for listening, connecting and registering channels
102+
/// </summary>
103+
/// <returns>The settings object</returns>
20104
object GetSettings();
105+
/// <summary>
106+
/// Shuts down the transport
107+
/// </summary>
21108
void Shutdown();
22109
}
23110
}

MLAPI/Data/Transports/LiteNetLib/LiteNetLibTransport.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using LiteNetLib;
1+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2+
using LiteNetLib;
23
using LiteNetLib.Utils;
34
using MLAPI.MonoBehaviours.Core;
45
using System.Collections.Generic;
@@ -230,3 +231,4 @@ public void OnNetworkLatencyUpdate(NetPeer peer, int latency)
230231
}
231232
}
232233
}
234+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

MLAPI/Data/Transports/NetEventType.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
namespace MLAPI.Data
22
{
3+
/// <summary>
4+
/// Represents a netEvent when polling
5+
/// </summary>
36
public enum NetEventType
47
{
8+
/// <summary>
9+
/// New data is received
10+
/// </summary>
511
Data,
12+
/// <summary>
13+
/// A client is connected, or client connected to server
14+
/// </summary>
615
Connect,
16+
/// <summary>
17+
/// A client disconnected, or client disconnected from server
18+
/// </summary>
719
Disconnect,
20+
/// <summary>
21+
/// No new event
22+
/// </summary>
823
Nothing
924
}
1025
}

MLAPI/Data/Transports/UNET/NetId.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ public uint GetClientId()
7070
{
7171
return HostId | (uint)((ConnectionId & 0xFF) << 8) | (uint)(((ConnectionId >> 8) & 0xFF) << 16) | (uint)(Meta << 24);
7272
}
73-
// Rider generated vvv
7473
/// <summary>
75-
/// Determines whether the specified <see cref="object"/> is equal to the current <see cref="T:MLAPI.Data.NetId"/>.
74+
/// Checks if two NetId's are equal
7675
/// </summary>
77-
/// <param name="obj">The <see cref="object"/> to compare with the current <see cref="T:MLAPI.Data.NetId"/>.</param>
78-
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to the current <see cref="T:MLAPI.Data.NetId"/>;
79-
/// otherwise, <c>false</c>.</returns>
76+
/// <param name="obj">NetId to compare to</param>
77+
/// <returns>Wheter or not the two NetIds are equal</returns>
8078
public override bool Equals (object obj)
8179
{
8280
if (obj == null || GetType() != obj.GetType())
@@ -85,34 +83,30 @@ public override bool Equals (object obj)
8583
NetId key = (NetId)obj;
8684
return (HostId == key.HostId) && (ConnectionId == key.ConnectionId);
8785
}
88-
// Rider generated vvv
8986
/// <summary>
90-
/// Serves as a hash function for a <see cref="T:MLAPI.Data.NetId"/> object.
87+
/// Returns a hash code for the instance
9188
/// </summary>
92-
/// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
93-
/// hash table.</returns>
89+
/// <returns>Returns a hash code for the instance</returns>
9490
public override int GetHashCode()
9591
{
9692
return (int)GetClientId();
9793
}
98-
// Rider generated vvv
9994
/// <summary>
100-
/// Determines whether a specified instance of <see cref="MLAPI.Data.NetId"/> is equal to another specified <see cref="MLAPI.Data.NetId"/>.
95+
/// Checks if two NetId's are equal
10196
/// </summary>
102-
/// <param name="client1">The first <see cref="MLAPI.Data.NetId"/> to compare.</param>
103-
/// <param name="client2">The second <see cref="MLAPI.Data.NetId"/> to compare.</param>
104-
/// <returns><c>true</c> if <c>client1</c> and <c>client2</c> are equal; otherwise, <c>false</c>.</returns>
97+
/// <param name="client1">First netId</param>
98+
/// <param name="client2">Second netId</param>
99+
/// <returns>Wheter or not the two NetIds are equal</returns>
105100
public static bool operator ==(NetId client1, NetId client2)
106101
{
107102
return (client1.HostId == client2.HostId && client1.ConnectionId == client2.ConnectionId) || (client1.IsHost() == client2.IsHost());
108103
}
109-
// Rider generated vvv
110104
/// <summary>
111-
/// Determines whether a specified instance of <see cref="MLAPI.Data.NetId"/> is not equal to another specified <see cref="MLAPI.Data.NetId"/>.
105+
/// Checks if two NetId's are not equal
112106
/// </summary>
113-
/// <param name="client1">The first <see cref="MLAPI.Data.NetId"/> to compare.</param>
114-
/// <param name="client2">The second <see cref="MLAPI.Data.NetId"/> to compare.</param>
115-
/// <returns><c>true</c> if <c>client1</c> and <c>client2</c> are not equal; otherwise, <c>false</c>.</returns>
107+
/// <param name="client1">First netId</param>
108+
/// <param name="client2">Second netId</param>
109+
/// <returns>Wheter or not the two NetIds are not equal</returns>
116110
public static bool operator !=(NetId client1, NetId client2)
117111
{
118112
return !(client1 == client2);

MLAPI/Data/Transports/UNET/UnetTransport.cs

Lines changed: 3 additions & 1 deletion
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 UnityEngine.Networking;
@@ -181,3 +182,4 @@ public void Connect(string address, int port, object settings, out byte error)
181182
}
182183
}
183184
}
185+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

0 commit comments

Comments
 (0)