mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
Phase 12: Coordinator deployment files, join/claim commands and UI, access options for published realms
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71e1488336
commit
2caa687490
18 files changed
+856
-8
No files matched your search
@@ -93,6 +93,8 @@ pub struct RealmPublishStatus {
|
||||
pub description: String,
|
||||
pub language: String,
|
||||
pub region: Option<String>,
|
||||
pub existing_only: bool,
|
||||
pub route: Option<String>,
|
||||
pub metadata_revision: Option<u64>,
|
||||
pub last_ok_unix: Option<i64>,
|
||||
pub last_error: Option<String>,
|
||||
@@ -284,6 +286,25 @@ impl RegistryHost {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// How joining players reach this realm: whether it creates accounts for them, and an address a game client can use right now. The realm has to have been published
|
||||
/// before (the choices live with its publishing settings); they take effect at the next heartbeat and on the control link at once.
|
||||
pub fn set_access(&mut self, local_id: &str, existing_only: bool, route: Option<&str>) -> Result<()> {
|
||||
let route = route.map(str::trim).filter(|r| !r.is_empty()).map(settings::validate_route).transpose()?;
|
||||
let Some(cfg) = self.settings.realms.get_mut(local_id) else { return Err(Error::Invalid("Publish this realm first.".into())) };
|
||||
let before = cfg.clone();
|
||||
cfg.existing_only = existing_only;
|
||||
cfg.route = route;
|
||||
let cfg = cfg.clone();
|
||||
if let Err(e) = self.save() {
|
||||
self.settings.realms.insert(local_id.to_string(), before);
|
||||
return Err(e);
|
||||
}
|
||||
if let Some(p) = self.publishers.get_mut(local_id) {
|
||||
p.cfg = cfg;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Stop publishing: the realm is unpublished at the Registry (retried in the background); its identity is kept for a later republication.
|
||||
pub fn unpublish(&mut self, local_id: &str, now: Instant) -> Result<()> {
|
||||
let Some(cfg) = self.settings.realms.get_mut(local_id) else { return Ok(()) };
|
||||
@@ -327,6 +348,8 @@ impl RegistryHost {
|
||||
description: p.cfg.description.clone(),
|
||||
language: p.cfg.language.clone(),
|
||||
region: p.cfg.region.clone(),
|
||||
existing_only: p.cfg.existing_only,
|
||||
route: p.cfg.route.clone(),
|
||||
metadata_revision: p.revision,
|
||||
last_ok_unix: p.last_ok,
|
||||
last_error: p.last_error.clone(),
|
||||
|
||||
@@ -16,6 +16,7 @@ enum Cmd {
|
||||
SetUrl(Option<String>, Sender<Result<()>>),
|
||||
Publish { local_id: String, name: String, description: String, language: String, region: Option<String>, reply: Sender<Result<()>> },
|
||||
Unpublish(String, Sender<Result<()>>),
|
||||
SetAccess { local_id: String, existing_only: bool, route: Option<String>, reply: Sender<Result<()>> },
|
||||
Retry(String),
|
||||
Shutdown,
|
||||
}
|
||||
@@ -50,6 +51,9 @@ impl RegistryRuntime {
|
||||
Ok(Cmd::Unpublish(local_id, reply)) => {
|
||||
let _ = reply.send(host.unpublish(&local_id, Instant::now()));
|
||||
}
|
||||
Ok(Cmd::SetAccess { local_id, existing_only, route, reply }) => {
|
||||
let _ = reply.send(host.set_access(&local_id, existing_only, route.as_deref()));
|
||||
}
|
||||
Ok(Cmd::Retry(local_id)) => host.retry(&local_id, Instant::now()),
|
||||
Err(RecvTimeoutError::Timeout) => {}
|
||||
}
|
||||
@@ -85,6 +89,10 @@ impl RegistryRuntime {
|
||||
self.ask(|reply| Cmd::Unpublish(local_id.into(), reply))
|
||||
}
|
||||
|
||||
pub fn set_access(&self, local_id: &str, existing_only: bool, route: Option<&str>) -> Result<()> {
|
||||
self.ask(|reply| Cmd::SetAccess { local_id: local_id.into(), existing_only, route: route.map(str::to_string), reply })
|
||||
}
|
||||
|
||||
pub fn retry(&self, local_id: &str) {
|
||||
let _ = self.tx.send(Cmd::Retry(local_id.into()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user