You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,8 +115,9 @@ A message can be send by calling `SendString` for a text message or `SendBytes`
115
115
116
116
#### Closing a connection
117
117
118
-
The connection can be closed by calling `Close`. Calling this method will send a closing message over the line. You can optional specify a `WebSocketCloseStatus` and description on the reason for closing for debugging purposes.
119
-
Whenever a connection is closed the event `Closed` is fired.
118
+
The connection can be closed by calling `Close`. Calling this method will send a closing message over the line. You can optional specify a `WebSocketCloseStatus` and description on the reason for closing for debugging purposes (the description is only sent together with a status, it's ignored with the default `WebSocketCloseStatus.Empty`).
119
+
`Close` doesn't block: the closing message is sent after the messages already queued and the connection is closed when the other end answers it, or after `ServerTimeout`. Closing with `WebSocketCloseStatus.EndpointUnavailable` is synchronous: the call returns after the closing message is sent and the connection is closed, without waiting for an answer. It waits at most `ServerTimeout` for the closing message to be sent; if that expires first the connection is closed anyway and the closing message may not have been sent. Messages still queued may not be sent.
120
+
Whenever a connection is closed the event `ConnectionClosed` is fired.
Copy file name to clipboardExpand all lines: WebSockets/WebSocket.cs
+52-22Lines changed: 52 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -218,26 +218,38 @@ public bool SendBytes(byte[] data, int fragmentSize = -1)
218
218
}
219
219
220
220
/// <summary>
221
-
/// Will start closing the WebSocket connection using the close handshake defined in the WebSocket protocol specification section 7.
221
+
/// Will start closing the WebSocket connection using the close handshake defined in the <see cref="WebSocket"/> protocol specification section 7.
222
222
/// </summary>
223
223
/// <param name="closeStatus">Indicates the reason for closing the WebSocket connection.</param>
224
224
/// <param name="statusDescription">Specifies a human readable explanation as to why the connection is closed.</param>
225
225
/// <remarks>
226
-
/// WebSocketCloseStatus.EndpointUnavailable will close the WebSocket synchronous without awaiting response.
226
+
/// <para>
227
+
/// This method doesn't block. The close message is sent after the messages already queued and <see cref="ConnectionClosed"/> is raised
228
+
/// when the remote endpoint answers the close message, or after <see cref="ServerTimeout"/> if it doesn't.
229
+
/// </para>
230
+
/// <para>
231
+
/// <see cref="WebSocketCloseStatus.EndpointUnavailable"/> will close the <see cref="WebSocket"/> synchronous without awaiting response.
232
+
/// The call blocks until the close message is sent, waiting at most <see cref="ServerTimeout"/> (5 seconds if it's infinite).
233
+
/// If that time expires first, the connection is closed anyway and the close message may not have been sent.
234
+
/// Messages still queued may not be sent.
235
+
/// </para>
236
+
/// <para>
237
+
/// Only has effect if the connection is open. With <see cref="WebSocketCloseStatus.Empty"/> no status code is sent, so <paramref name="statusDescription"/> is ignored.
0 commit comments