pub struct WebSocket { /* private fields */ }Expand description
A WebSocket connection being monitored.
This struct represents an active WebSocket connection and provides methods to register handlers for frame events.
Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
Get the request ID for this WebSocket.
Sourcepub async fn on_framesent<F, Fut>(&self, handler: F)
pub async fn on_framesent<F, Fut>(&self, handler: F)
Register a handler for frame sent events.
The handler will be called whenever a frame is sent over this WebSocket.
§Example
use viewpoint_core::WebSocket;
websocket.on_framesent(|frame| async move {
println!("Sent: {:?}", frame.payload());
}).await;Sourcepub async fn on_framereceived<F, Fut>(&self, handler: F)
pub async fn on_framereceived<F, Fut>(&self, handler: F)
Register a handler for frame received events.
The handler will be called whenever a frame is received on this WebSocket.
§Example
use viewpoint_core::WebSocket;
websocket.on_framereceived(|frame| async move {
println!("Received: {:?}", frame.payload());
}).await;Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebSocket
impl RefUnwindSafe for WebSocket
impl Send for WebSocket
impl Sync for WebSocket
impl Unpin for WebSocket
impl UnwindSafe for WebSocket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more