Skip to main content

WebSocketMonitor

Struct WebSocketMonitor 

Source
pub struct WebSocketMonitor { /* private fields */ }
Expand description

WebSocket monitor for tracking connections

Implementations§

Source§

impl WebSocketMonitor

Source

pub fn new() -> Self

Create a new WebSocket monitor

Source

pub fn start(&mut self)

Start monitoring

Source

pub fn stop(&mut self)

Stop monitoring

Source

pub const fn is_active(&self) -> bool

Check if monitoring is active

Source

pub fn mock(&mut self, mock: WebSocketMock)

Add a mock rule

Source

pub fn connect(&mut self, url: &str) -> String

Create a new connection

Source

pub fn disconnect(&mut self, connection_id: &str, code: u16, reason: &str)

Close a connection

Source

pub fn send(&mut self, connection_id: &str, message: &str)

Send a message on a connection

Source

pub fn receive(&self, connection_id: &str, message: &str)

Receive a message on a connection

Source

pub fn take_pending_responses(&mut self) -> Vec<(String, MockWebSocketResponse)>

Get pending mock responses

Source

pub fn connections(&self) -> Vec<String>

Get all connections

Source

pub fn get_connection( &self, connection_id: &str, ) -> Option<Vec<WebSocketMessage>>

Get connection by ID

Source

pub fn all_messages(&self) -> Vec<WebSocketMessage>

Get all messages across all connections

Source

pub fn connection_count(&self) -> usize

Get connection count

Source

pub fn active_connection_count(&self) -> usize

Get active connection count

Source

pub fn assert_sent(&self, pattern: &str) -> ProbarResult<()>

Assert a message was sent

Source

pub fn assert_received(&self, pattern: &str) -> ProbarResult<()>

Assert a message was received

Source

pub fn assert_connected(&self, url_pattern: &str) -> ProbarResult<()>

Assert connection was made to URL

Source

pub fn clear(&mut self)

Clear all connections

Trait Implementations§

Source§

impl Debug for WebSocketMonitor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WebSocketMonitor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.