File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,19 @@ pub struct WebSocketConnection(
20
20
) ;
21
21
22
22
impl WebSocketConnection {
23
- /// Sends a string message to the connected websocket client
24
- pub async fn send_string ( & self , s : String ) -> async_tungstenite:: tungstenite:: Result < ( ) > {
25
- self . 0 . lock ( ) . send ( Message :: Text ( s) ) . await ?;
26
- Ok ( ( ) )
23
+ /// Sends a string message to the connected websocket client. This is equivalent to `.send(Message::Text(string))`
24
+ pub async fn send_string ( & self , string : String ) -> async_tungstenite:: tungstenite:: Result < ( ) > {
25
+ self . send ( Message :: Text ( string) ) . await
27
26
}
28
27
29
- /// Sends a binary message to the connected websocket client
28
+ /// Sends a binary message to the connected websocket client. This is equivalent to `.send(Message::Binary(bytes))`
30
29
pub async fn send_bytes ( & self , bytes : Vec < u8 > ) -> async_tungstenite:: tungstenite:: Result < ( ) > {
31
- self . 0 . lock ( ) . send ( Message :: Binary ( bytes) ) . await ?;
30
+ self . send ( Message :: Binary ( bytes) ) . await
31
+ }
32
+
33
+ /// Sends a [`Message`] to the client
34
+ pub async fn send ( & self , message : Message ) -> async_tungstenite:: tungstenite:: Result < ( ) > {
35
+ self . 0 . lock ( ) . send ( message) . await ?;
32
36
Ok ( ( ) )
33
37
}
34
38
You can’t perform that action at this time.
0 commit comments