Trait jamsocket_wasm::prelude::SimpleJamsocketService[][src]

pub trait SimpleJamsocketService: 'static + Unpin + Send + Sync {
    fn new(room_id: &str, context: &impl JamsocketContext) -> Self;

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

Re-exports useful items from jamsocket and jamsocket_wasm_macro. A simplified interface for creating a JamsocketService that can be exposed as a WebAssembly module.

See module documentation for usage examples.

Required methods

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

Provided methods

Called each time a client connects to the service.

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

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

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

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

Implementors