memory
ModuleAn in-process adapter: connections, messages and requests are driven by calls, and what the server sends is recorded.
Contents
Structs
ClosedA connection the server closed.FrameA message the server sent to one connection.Memory- `start`(Adapter::start) calls the start hook, then the worker start hook for each worker (`0` to the worker number, one by default); `shutdown`(Adapter::shutdown) calls the worker stop hook for each worker of a started server. - `send`(Adapter::send) records a `Frame` for each open connection in the list and skips the others. - `close`(Adapter::close) closes an open connection, records it and calls the close hook, as Swoole does. - `fail`(Memory::fail) makes one stage fail, to exercise `Server::error`(crate::Server::error).SettingsWhat the configuration setters were given; `None` for a setter not called.use utopia_websocket::memory::Closed;Rust
pub struct ClosedA connection the server closed.
use utopia_websocket::memory::Frame;Rust
pub struct FrameA message the server sent to one connection.
use utopia_websocket::Memory;Rust
pub struct Memorystartcalls the start hook, then the worker start hook for each worker (0to the worker number, one by default);shutdowncalls the worker stop hook for each worker of a started server.sendrecords aFramefor each open connection in the list and skips the others.closecloses an open connection, records it and calls the close hook, as Swoole does.failmakes one stage fail, to exerciseServer::error.
Clones share the same server.
Rust
use utopia_websocket::{Memory, Server};
let adapter = Memory::new();
let server = Server::new(adapter.clone());
server.on_open(|connection, _| println!("connected {connection}"));
adapter.open(7, &Default::default());
server.send(&[7, 8], "hello");
assert_eq!(adapter.frames().len(), 1); // 8 is not open
assert_eq!(adapter.connections(), [7]);use utopia_websocket::memory::Settings;Rust
pub struct SettingsWhat the configuration setters were given; None for a setter not
called.