File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -2848,17 +2848,19 @@ public void SendAsync (FileInfo file, Action<bool> completed)
28482848 /// </param>
28492849 public void SendAsync ( string data , Action < bool > completed )
28502850 {
2851- var msg = _readyState . CheckIfAvailable ( false , true , false , false ) ??
2852- CheckSendParameter ( data ) ;
2851+ if ( _readyState != WebSocketState . Open ) {
2852+ var msg = "The current state of the connection is not Open." ;
2853+ throw new InvalidOperationException ( msg ) ;
2854+ }
28532855
2854- if ( msg != null ) {
2855- _logger . Error ( msg ) ;
2856- error ( "An error has occurred in sending data." , null ) ;
2856+ if ( data == null )
2857+ throw new ArgumentNullException ( "data" ) ;
28572858
2858- return ;
2859- }
2859+ byte [ ] bytes ;
2860+ if ( ! data . TryGetUTF8EncodedBytes ( out bytes ) )
2861+ throw new ArgumentException ( "Cannot be UTF8 encoded." , "data" ) ;
28602862
2861- sendAsync ( Opcode . Text , new MemoryStream ( data . UTF8Encode ( ) ) , completed ) ;
2863+ sendAsync ( Opcode . Text , new MemoryStream ( bytes ) , completed ) ;
28622864 }
28632865
28642866 /// <summary>
You can’t perform that action at this time.
0 commit comments