Skip to main content

register_do_subscriber

Function register_do_subscriber 

Source
pub fn register_do_subscriber(
    shard: Arc<dyn DynShard>,
    subscriber_id: SubscriberId,
    ws_send: impl Fn(&[u8]) + Send + Sync + 'static,
    auth: ShardAuth,
) -> Result<DoSubscriberHandle, String>
Expand description

Registers a WebSocket-connected player with a shard running inside a DO.

The caller’s DO fetch handler:

  1. Accepts the WebSocket upgrade.
  2. Gets a reference to the shard (held in DO-scoped state).
  3. Calls this function with the WS send closure and the resolved auth.

Returns a close handler — call it in the DO’s webSocketClose event.