Skip to main content

AroraWSServer

Struct AroraWSServer 

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

WebSocket server for the arora protocol.

Handles connections, parses messages, and dispatches to registered handlers. Supports at most one active client at a time – when a new client connects, the previous one is disconnected.

Implementations§

Source§

impl AroraWSServer

Source

pub fn new(config: ServerConfig) -> Self

Create a new server with the given configuration.

Source

pub fn with_port(port: u16) -> Self

Create a new server with default configuration.

Source

pub fn push(&self, msg: Outgoing)

Push a server-initiated message to the connected client(s).

Source

pub fn subscribe(&self) -> Receiver<Outgoing>

Subscribe to the outbound push channel.

Source

pub fn registry(&self) -> &Arc<Registry>

Get a reference to the registry.

Source

pub async fn set_set_slot_values_handler<F>(&self, handler: F)
where F: Fn(HashMap<String, Value>) -> Result<(), String> + Send + Sync + 'static,

Set the update handler callback. This is called whenever a valid update message is received.

Source

pub async fn set_get_slot_values_handler(&self, handler: GetSlotValuesHandler)

Set the get slot values handler callback. This is called whenever a valid get slot values message is received.

Source

pub async fn set_on_client_connected_handler( &self, handler: OnClientConnectedHandler, )

Set the handler called when a new client connects.

Source

pub async fn disconnect_client(&self)

Disconnect the current active client (if any).

Source

pub async fn is_running(&self) -> bool

Check if the server is running.

Source

pub fn port(&self) -> u16

Get the configured port.

Source

pub async fn run(&self, cancel_token: CancellationToken) -> Result<(), String>

Run the server until the cancellation token is triggered.

Source

pub fn connection_id(&self) -> String

Get the connection identifier.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V