Skip to content

Commit 75ee4ce

Browse files
committed
Final tweaks on documentation comments and formatting
1 parent 67e9b4a commit 75ee4ce

File tree

5 files changed

+105
-120
lines changed

5 files changed

+105
-120
lines changed

Websockets/ClientWebSocket/ClientWebSocket.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
namespace System.Net.WebSockets
1414
{
15+
/// <summary>
16+
/// Describes the method that will handle the event that's fired when a message that has been subscribed to has been received.
17+
/// </summary>
18+
/// <param name="sender">The proximity device that received the message.</param>
19+
/// <param name="e">The proximity device that received the message.</param>
1520
public delegate void MessageReceivedEventHandler(object sender, MessageReceivedEventArgs e);
1621

1722
/// <summary>
@@ -20,7 +25,7 @@ namespace System.Net.WebSockets
2025
public class ClientWebSocket : WebSocket, IDisposable
2126
{
2227
private NetworkStream _networkStream;
23-
28+
2429
private X509Certificate _certificate = null;
2530

2631
/// <summary>
@@ -46,6 +51,9 @@ public class ClientWebSocket : WebSocket, IDisposable
4651
/// </summary>
4752
public string Host { get; private set; }
4853

54+
/// <summary>
55+
/// Option to use a custom certificate for authentication.
56+
/// </summary>
4957
public bool UseCustomCertificate => _certificate != null;
5058

5159
/// <summary>
@@ -91,10 +99,10 @@ public X509Certificate CACertificate
9199
/// <param name="options">Optional <see cref="ClientWebSocketOptions"/> where extra options can be defined.</param>
92100
public ClientWebSocket(ClientWebSocketOptions options = null) : base(options)
93101
{
94-
if(options != null)
102+
if (options != null)
95103
{
96104
SslProtocol = options.SslProtocol;
97-
SslVerification = options.SslVerification;
105+
SslVerification = options.SslVerification;
98106
_certificate = options.Certificate;
99107
}
100108
}
@@ -103,11 +111,10 @@ public ClientWebSocket(ClientWebSocketOptions options = null) : base(options)
103111
/// Connect to a WebSocket server.
104112
/// </summary>
105113
/// <param name="uri">The URI of the WebSocket server to connect to.</param>
106-
/// <param name="messageReceivedHandler">A handler that is called when the WebSocket server receives a message</param>
107114
public void Connect(string uri)
108115
{
109116
State = WebSocketFrame.WebSocketState.Connecting;
110-
117+
111118
var splitUrl = uri.Split(new char[] { ':', '/', '/' }, 4);
112119

113120
if (splitUrl.Length == 4 && splitUrl[0] == "ws")
@@ -161,6 +168,7 @@ public void Connect(string uri)
161168
_tcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
162169

163170
NetworkStream stream = null;
171+
164172
try
165173
{
166174
_tcpSocket.Connect(ep);
@@ -204,9 +212,9 @@ private void WebSocket_ConnectionClosed(object sender, EventArgs e)
204212
_tcpSocket.Close();
205213
}
206214

207-
private void WebSocketClientConnect(IPEndPoint remoteEndPoint, string prefix = "/", string host = null )
215+
private void WebSocketClientConnect(IPEndPoint remoteEndPoint, string prefix = "/", string host = null)
208216
{
209-
if (prefix[0] != '/') throw new Exception("websocket prefix has to start with '/'");
217+
if (prefix[0] != '/') throw new Exception("websocket prefix has to start with '/'");
210218

211219
byte[] keyBuf = new byte[16];
212220
new Random().NextBytes(keyBuf);
@@ -226,10 +234,10 @@ private void WebSocketClientConnect(IPEndPoint remoteEndPoint, string prefix = "
226234
if (bytesRead == bufferStart.Length)
227235
{
228236
if (Encoding.UTF8.GetString(bufferStart, 0, bufferStart.Length).ToLower() == beginHeader)
229-
{
237+
{
230238
//right http request
231239
bytesRead = _networkStream.Read(buffer, 0, buffer.Length);
232-
240+
233241
if (bytesRead > 20)
234242
{
235243
var headers = WebSocketHelpers.ParseHeaders(Encoding.UTF8.GetString(buffer, 0, bytesRead));

Websockets/ClientWebSocket/ClientWebSocketOptions.cs

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

1010
namespace System.Net.WebSockets
1111
{
12+
/// <summary>
13+
/// Options to use with a <see cref="ClientWebSocket"/> object.
14+
/// </summary>
1215
public class ClientWebSocketOptions : WebSocketOptions
1316
{
1417
/// <summary>

Websockets/WebSocket.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public abstract class WebSocket : IDisposable
6666
/// <value>
6767
/// The maximum allowed byte length of a partial message send by the WebSocket.
6868
/// </value>
69+
/// </summary>
6970
public int MaxFragmentSize { get; private set; } = 1024;
7071

7172
/// <summary>
@@ -334,19 +335,6 @@ private void OnWriteError(object sender, WebSocketWriteErrorEventArgs e)
334335
}
335336
}
336337

337-
//private void RelayMessage(ReceiveMessageFrame messageFrame)
338-
//{
339-
// if (messageFrame.Error)
340-
// {
341-
/// Debug.WriteLine($"{RemoteEndPoint.ToString()} error - {messageFrame.ErrorMessage}");
342-
/// RawClose(messageFrame.CloseStatus, Encoding.UTF8.GetBytes(messageFrame.ErrorMessage), true);
343-
// }
344-
// else
345-
// {
346-
/// LastContact = DateTime.UtcNow;
347-
/// OnNewMessage(messageFrame);
348-
// }
349-
//}
350338

351339
//Ping will only commence from this thread because of threading safety.
352340
internal void SendPing(string pingContent = "hello")

Websockets/WebSocketFrame/WebSocketState.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public enum WebSocketState
2727

2828
/// <summary>
2929
/// A close message was sent to the remote endpoint.
30+
/// </summary>
3031
CloseSent = 3,
3132

3233
/// <summary>

0 commit comments

Comments
 (0)