Plugin Basics
Custom plugins are a collection of modules:
<plugin>-core
: A module shared by the server and client.<plugin>-client
: The client plugin to send data to the desktop client.<plugin>-desktop
: The desktop client plugin containing UI and server logic.
Common Plugin
Desktop Plugin
class MyDesktopPlugin : ServerPlugin<Unit, ClientMessage> {
private val batteryPercentFlow = MutableStateFlow(0f)
override fun handleMessage(message: ClientMessage) {
batteryPercentFlow.value = message.batteryPercent
}
override val ui = UiHooks {
MainPanel { modifier ->
val batteryPercent by batteryPercentFlow.collectAsState()
Column(modifier = modifier) {
Text("Battery:")
ProgressBar(batteryPercent)
}
}
}
}