mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-18 19:25:56 +00:00
Restore remote portable progress and resilient relay connections
This commit is contained in:
1 parent
9e9778af74
commit
b61a186470
27 files changed
+2579
-145
No files matched your search
@@ -72,6 +72,9 @@ pub(crate) fn start(
|
||||
None
|
||||
}
|
||||
};
|
||||
if let (Some(player), Some(portable)) = (&player, &portable) {
|
||||
PlayerControl::start_remote_session_sync(player, portable);
|
||||
}
|
||||
let host = portable.and_then(|portable| {
|
||||
let store = match ControlStore::open(&base.join("host")) {
|
||||
Ok(s) => Arc::new(Mutex::new(s)),
|
||||
@@ -280,12 +283,46 @@ pub(crate) async fn join_realm(
|
||||
out.status = "incompatible".into();
|
||||
return Ok(out);
|
||||
}
|
||||
let here = pc_bg.claimed_here(&rid_bg).map_err(from_control)?;
|
||||
if !here.iter().any(|(id, _)| id.to_string() == character) {
|
||||
// Phase 12.1: Transfer canonical character to remote Host over the encrypted control channel
|
||||
let owned_realm =
|
||||
coa_core::realm_registry::settings::load(&data_dir().join("registry"))
|
||||
.map_err(|e| fail("registry", e.to_string()))?
|
||||
.realms
|
||||
.into_iter()
|
||||
.find(|(_, cfg)| cfg.enabled && cfg.realm_id == Some(rid_bg))
|
||||
.map(|(local_id, _)| local_id);
|
||||
if let Some(local_id) = owned_realm {
|
||||
if let Some(pending) = pc_bg
|
||||
.pending_remote_sessions()
|
||||
.map_err(from_control)?
|
||||
.into_iter()
|
||||
.find(|pending| pending.character_id.to_string() == character)
|
||||
{
|
||||
pc_bg
|
||||
.leave_idle_remote_session(pending.character_id, &portable)
|
||||
.map_err(from_control)?;
|
||||
}
|
||||
let username = out.username.clone();
|
||||
portable.call(move |service| {
|
||||
service.play(&character, &local_id, username.as_deref())
|
||||
})??;
|
||||
} else {
|
||||
if let Some(pending) = pc_bg
|
||||
.pending_remote_sessions()
|
||||
.map_err(from_control)?
|
||||
.into_iter()
|
||||
.find(|pending| {
|
||||
pending.character_id.to_string() == character
|
||||
&& pending.realm_id != rid_bg.to_string()
|
||||
})
|
||||
{
|
||||
pc_bg
|
||||
.leave_idle_remote_session(pending.character_id, &portable)
|
||||
.map_err(from_control)?;
|
||||
}
|
||||
let char_id_str = character.clone();
|
||||
let bundle =
|
||||
portable.call(move |s| s.export_for_remote_transfer(&char_id_str))??;
|
||||
let remote_realm = rid_bg.to_string();
|
||||
let (bundle, session, revision) = portable
|
||||
.call(move |s| s.prepare_remote_transfer(&char_id_str, &remote_realm))??;
|
||||
if bundle.ruleset.as_str() != detail.ruleset.as_str() {
|
||||
ch.close();
|
||||
return Err(fail(
|
||||
@@ -299,11 +336,12 @@ pub(crate) async fn join_realm(
|
||||
}
|
||||
let cuuid = bundle.character_id.as_uuid();
|
||||
let _outcome = pc_bg
|
||||
.transfer_character(
|
||||
.transfer_owned_character(
|
||||
&mut ch,
|
||||
session,
|
||||
cuuid,
|
||||
bundle.ruleset.as_str(),
|
||||
1,
|
||||
revision,
|
||||
&bundle.payload,
|
||||
bundle.content_hash,
|
||||
bundle.collections,
|
||||
|
||||
Reference in new issue
Block a user