[pbs-devel] [PATCH proxmox 7/9] proxmox/tools/websocket: implement send_control_frame for writer

Dominik Csapak d.csapak at proxmox.com
Tue Jul 14 13:09:55 CEST 2020


so that we can easily send a control frame to the endpoint

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 proxmox/src/tools/websocket.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/proxmox/src/tools/websocket.rs b/proxmox/src/tools/websocket.rs
index cd09add..2a2bfa4 100644
--- a/proxmox/src/tools/websocket.rs
+++ b/proxmox/src/tools/websocket.rs
@@ -194,6 +194,11 @@ impl<W: AsyncWrite + Unpin> WebSocketWriter<W> {
             frame: None,
         }
     }
+
+    pub async fn send_control_frame(&mut self, mask: Option<[u8; 4]>, opcode: OpCode, data: &[u8]) -> Result<(), Error> {
+        let frame = create_frame(mask, data, opcode)?;
+        self.writer.write_all(&frame).await.map_err(Error::from)
+    }
 }
 
 impl<W: AsyncWrite + Unpin> AsyncWrite for WebSocketWriter<W> {
-- 
2.20.1






More information about the pbs-devel mailing list