Add JSON-RPC interface and refactor for MCP support
All checks were successful
Smoke tests / Build and smoke test (push) Successful in 1h0m43s

This commit is contained in:
AI Agent
2026-03-16 19:19:21 -06:00
parent 4e41038555
commit dd517d8851
10 changed files with 380 additions and 116 deletions

View File

@@ -80,7 +80,7 @@ impl MudHandler {
if let Some(saved) = saved {
let handle = session.handle();
let mut state = self.state.lock().await;
state.load_existing_player(self.id, saved, channel, handle);
state.load_existing_player(self.id, saved, Some(channel), Some(handle));
drop(state);
let msg = format!(
@@ -127,7 +127,13 @@ impl MudHandler {
let others: Vec<_> = state
.players_in_room(&room_id, self.id)
.iter()
.map(|c| (c.channel, c.handle.clone()))
.filter_map(|c| {
if let (Some(ch), Some(h)) = (c.channel, &c.handle) {
Some((ch, h.clone()))
} else {
None
}
})
.collect();
let room_view = render_entry_room(&state, &room_id, &player_name, self.id);
@@ -170,8 +176,8 @@ impl MudHandler {
self.username.clone(),
race_id,
class_id,
channel,
handle,
Some(channel),
Some(handle),
);
state.save_player_to_db(self.id);
drop(state);
@@ -203,7 +209,13 @@ impl MudHandler {
let others: Vec<_> = state
.players_in_room(&conn.player.room_id, self.id)
.iter()
.map(|c| (c.channel, c.handle.clone()))
.filter_map(|c| {
if let (Some(ch), Some(h)) = (c.channel, &c.handle) {
Some((ch, h.clone()))
} else {
None
}
})
.collect();
drop(state);
for (ch, h) in others {
@@ -415,7 +427,7 @@ impl russh::server::Handler for MudHandler {
}
let keep_going =
commands::execute(&line, self.id, &self.state, session, channel)
commands::execute_for_ssh(&line, self.id, &self.state, session, channel)
.await?;
if !keep_going {
self.handle_disconnect().await;