Scorekeeper: share a sheet between devices
A host can share its score sheet and others nearby can join it, found the same way games are, or by typed address over a hotspot. - A joining guest is not let in on its own say-so. The host is prompted with the guest's name and answers Allow or Deny. A device already let in that drops out (locked phone) is let straight back; the host can remove anyone. - The host's sheet is authoritative. What travels is what was done (SheetOp: add round, rename, move column, ...), not whole sheets, so changes made at the same moment all land. A guest's own changes show at once and are laid over the host's sheet until confirmed (SheetReplica). - Sync asks the host for the sheet as it stands, and runs on its own when the app returns to the front, as it does for a game table. - Hello carries a purpose and hosts advertise one, so a game join screen does not list score sheets and a game guest typing a sheet's address is told so. - The Scorekeeper screen now expresses every edit as a SheetOp, so one grid serves a local sheet, a hosted one and a joined one. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CBG7URddsUZjQ6KE1Kqf6G
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
16f9321ca3
commit
89b19a894a
@@ -5,7 +5,9 @@ import android.provider.Settings as AndroidSettings
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import org.prolibertate.games.net.LanTransport
|
||||
import org.prolibertate.games.net.LobbyController
|
||||
import org.prolibertate.games.net.ScorekeeperSession
|
||||
import org.prolibertate.games.score.ScorekeeperRepository
|
||||
import org.prolibertate.games.settings.SettingsRepository
|
||||
import org.prolibertate.games.ui.AppEnv
|
||||
@@ -21,12 +23,23 @@ class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val peerId = stablePeerId()
|
||||
// Its own transport rather than the lobby's: both listen on the same
|
||||
// port, and a screen at a time is only ever using one of them.
|
||||
val scoreLan = LanTransport(applicationContext)
|
||||
|
||||
env = AppEnv(
|
||||
settingsRepository = SettingsRepository(applicationContext),
|
||||
updater = Updater(this),
|
||||
lobby = LobbyController(applicationContext, lifecycleScope),
|
||||
scorekeeper = ScorekeeperRepository(applicationContext),
|
||||
peerId = stablePeerId(),
|
||||
scoreSession = ScorekeeperSession(
|
||||
transport = scoreLan,
|
||||
endpoint = scoreLan.endpoint,
|
||||
scope = lifecycleScope,
|
||||
deviceId = peerId,
|
||||
),
|
||||
peerId = peerId,
|
||||
)
|
||||
|
||||
setContent {
|
||||
@@ -50,6 +63,9 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (::env.isInitialized) env.lobby.stop()
|
||||
if (::env.isInitialized) {
|
||||
env.lobby.stop()
|
||||
env.scoreSession.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user