pub trait SimpleStateroomService {
    // Required method
    fn new(room_id: &str, context: &impl StateroomContext) -> Self;

    // Provided methods
    fn connect(&mut self, client: ClientId, context: &impl StateroomContext) { ... }
    fn disconnect(&mut self, client: ClientId, context: &impl StateroomContext) { ... }
    fn message(
        &mut self,
        client: ClientId,
        message: &str,
        context: &impl StateroomContext
    ) { ... }
    fn binary(
        &mut self,
        client: ClientId,
        message: &[u8],
        context: &impl StateroomContext
    ) { ... }
    fn timer(&mut self, context: &impl StateroomContext) { ... }
}
Expand description

A simplified interface for creating a StateroomService that can be exposed as a WebAssembly module.

See module documentation for usage examples.

Required Methods§

source

fn new(room_id: &str, context: &impl StateroomContext) -> Self

Called when the service is created, before any client has had a chance to connect.

Provided Methods§

source

fn connect(&mut self, client: ClientId, context: &impl StateroomContext)

Called each time a client connects to the service.

source

fn disconnect(&mut self, client: ClientId, context: &impl StateroomContext)

Called each time a client disconnects from the service, unless that disconnection will cause the service to be destroyed.

source

fn message( &mut self, client: ClientId, message: &str, context: &impl StateroomContext )

Called each time a client sends a text message to the service.

source

fn binary( &mut self, client: ClientId, message: &[u8], context: &impl StateroomContext )

Called each time a client sends a binary message to the service.

source

fn timer(&mut self, context: &impl StateroomContext)

Called when StateroomContext::set_timer has been called on this service’s context, after the provided duration.

Implementors§