ClientManager

Manages connected clients and their WebSocket sessions.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
suspend fun assignRole(clientId: String, role: ClientRole, publisherClientId: String?)

Assigns a role to a client.

Link copied to clipboard
suspend fun broadcastClientList()

Broadcasts the current client list to all connected clients. Includes both real clients and ghost devices.

Link copied to clipboard
suspend fun broadcastGhostEvent(ghostId: String, message: DevToolsMessage)

Broadcasts a ghost device's events to all listeners.

Link copied to clipboard
suspend fun broadcastToListeners(publisherId: String, message: DevToolsMessage)

Broadcasts a message to all listeners of a publisher.

Link copied to clipboard
suspend fun getAllClients(): List<ClientInfo>

Gets all connected clients including ghost devices.

Link copied to clipboard
suspend fun getClient(clientId: String): ClientInfo?

Gets information about a specific client.

Link copied to clipboard
suspend fun getCurrentPublisher(): String?

Gets the current publisher ID.

Link copied to clipboard
suspend fun getGhostDevice(ghostId: String): GhostDevice?

Gets a ghost device by ID.

Link copied to clipboard
suspend fun isGhostDevice(clientId: String): Boolean

Checks if a client ID belongs to a ghost device.

Link copied to clipboard
suspend fun registerClient(session: WebSocketSession, registration: DevToolsMessage.ClientRegistration)

Registers a new client connection.

Link copied to clipboard

Registers a ghost device from an imported session. Ghost devices can be played back and will broadcast events to listeners.

Link copied to clipboard
suspend fun removeGhostDevice(ghostId: String)

Removes a ghost device.

Link copied to clipboard
suspend fun sendToPublisher(publisherId: String, message: DevToolsMessage)

Sends a message to the publisher client.

Link copied to clipboard
suspend fun setPublisher(clientId: String, reason: String)

Sets the current publisher. Only one publisher is allowed at a time. If the new publisher is a real device and there's a ghost publisher, the ghost is removed.

Link copied to clipboard
suspend fun unregisterClient(clientId: String)

Unregisters a client and removes all subscriptions.