@@ -8,32 +8,93 @@ namespace ObsWebSocket.Core.Networking;
88/// </summary>
99public interface IWebSocketConnection : IDisposable
1010{
11+ /// <summary>
12+ /// Gets the current state of the WebSocket connection.
13+ /// </summary>
1114 WebSocketState State { get ; }
15+
16+ /// <summary>
17+ /// Gets the current close status of the WebSocket connection, if available.
18+ /// </summary>
1219 WebSocketCloseStatus ? CloseStatus { get ; }
20+
21+ /// <summary>
22+ /// Gets the close status description of the WebSocket connection, if available.
23+ /// </summary>
1324 string ? CloseStatusDescription { get ; }
25+
26+ /// <summary>
27+ /// Gets the Subprotocol used for the WebSocket connection.
28+ /// </summary>
1429 string ? SubProtocol { get ; }
30+
31+ /// <summary>
32+ /// Gets the options used to configure the WebSocket connection.
33+ /// </summary>
1534 ClientWebSocketOptions Options { get ; }
1635
36+ /// <summary>
37+ /// Connects to the WebSocket server using the specified URI.
38+ /// </summary>
39+ /// <param name="uri"></param>
40+ /// <param name="cancellationToken"></param>
41+ /// <returns></returns>
1742 Task ConnectAsync ( Uri uri , CancellationToken cancellationToken ) ;
43+
44+ /// <summary>
45+ /// Sends a message to the WebSocket connection.
46+ /// </summary>
47+ /// <param name="buffer"></param>
48+ /// <param name="messageType"></param>
49+ /// <param name="endOfMessage"></param>
50+ /// <param name="cancellationToken"></param>
51+ /// <returns></returns>
1852 ValueTask SendAsync (
1953 ReadOnlyMemory < byte > buffer ,
2054 WebSocketMessageType messageType ,
2155 bool endOfMessage ,
2256 CancellationToken cancellationToken
2357 ) ;
58+
59+ /// <summary>
60+ /// Receives a message from the WebSocket connection and returns the result.
61+ /// </summary>
62+ /// <param name="buffer"></param>
63+ /// <param name="cancellationToken"></param>
64+ /// <returns></returns>
2465 ValueTask < ValueWebSocketReceiveResult > ReceiveAsync (
2566 Memory < byte > buffer ,
2667 CancellationToken cancellationToken
2768 ) ;
69+
70+ /// <summary>
71+ /// Closes the WebSocket connection and sends a close frame to the server.
72+ /// </summary>
73+ /// <param name="closeStatus"></param>
74+ /// <param name="statusDescription"></param>
75+ /// <param name="cancellationToken"></param>
76+ /// <returns></returns>
2877 Task CloseAsync (
2978 WebSocketCloseStatus closeStatus ,
3079 string ? statusDescription ,
3180 CancellationToken cancellationToken
3281 ) ;
82+
83+ /// <summary>
84+ /// Closes the output stream of the WebSocket connection without closing the connection itself.
85+ /// </summary>
86+ /// <param name="closeStatus"></param>
87+ /// <param name="statusDescription"></param>
88+ /// <param name="cancellationToken"></param>
89+ /// <returns></returns>
3390 Task CloseOutputAsync (
3491 WebSocketCloseStatus closeStatus ,
3592 string ? statusDescription ,
3693 CancellationToken cancellationToken
3794 ) ;
95+
96+ /// <summary>
97+ /// Aborts the WebSocket connection without sending a close frame.
98+ /// </summary>
3899 void Abort ( ) ;
39100}
0 commit comments