@@ -45,8 +45,18 @@ public class WsClient : HttpClient, IWebSocket
4545
4646 public override bool Connect ( ) { _syncConnect = true ; return base . Connect ( ) ; }
4747 public override bool ConnectAsync ( ) { _syncConnect = false ; return base . ConnectAsync ( ) ; }
48- public virtual bool Close ( int status ) { SendClose ( status , Span < byte > . Empty ) ; base . Disconnect ( ) ; return true ; }
49- public virtual bool CloseAsync ( int status ) { SendCloseAsync ( status , Span < byte > . Empty ) ; base . DisconnectAsync ( ) ; return true ; }
48+ public virtual bool Close ( int status ) => Close ( status , Span < byte > . Empty ) ;
49+ public virtual bool Close ( int status , string text ) => Close ( status , Encoding . UTF8 . GetBytes ( text ) ) ;
50+ public virtual bool Close ( int status , ReadOnlySpan < char > text ) => Close ( status , Encoding . UTF8 . GetBytes ( text . ToArray ( ) ) ) ;
51+ public virtual bool Close ( int status , byte [ ] buffer ) => Close ( status , buffer . AsSpan ( ) ) ;
52+ public virtual bool Close ( int status , byte [ ] buffer , long offset , long size ) => Close ( status , buffer . AsSpan ( ( int ) offset , ( int ) size ) ) ;
53+ public virtual bool Close ( int status , ReadOnlySpan < byte > buffer ) { SendClose ( status , buffer ) ; base . Disconnect ( ) ; return true ; }
54+ public virtual bool CloseAsync ( int status ) => CloseAsync ( status , Span < byte > . Empty ) ;
55+ public virtual bool CloseAsync ( int status , string text ) => CloseAsync ( status , Encoding . UTF8 . GetBytes ( text ) ) ;
56+ public virtual bool CloseAsync ( int status , ReadOnlySpan < char > text ) => CloseAsync ( status , Encoding . UTF8 . GetBytes ( text . ToArray ( ) ) ) ;
57+ public virtual bool CloseAsync ( int status , byte [ ] buffer ) => CloseAsync ( status , buffer . AsSpan ( ) ) ;
58+ public virtual bool CloseAsync ( int status , byte [ ] buffer , long offset , long size ) => CloseAsync ( status , buffer . AsSpan ( ( int ) offset , ( int ) size ) ) ;
59+ public virtual bool CloseAsync ( int status , ReadOnlySpan < byte > buffer ) { SendClose ( status , buffer ) ; base . DisconnectAsync ( ) ; return true ; }
5060
5161 #endregion
5262
0 commit comments