feat(stub): implement ADR-0047 tools/list_changed on reconnect
This commit is contained in:
1 parent
9e02639d0d
commit
33b1a4e3e6
1 file changed
+16
@@ -56,6 +56,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let ws_url = format!("{ws_url}/ws?client=proxy");
|
let ws_url = format!("{ws_url}/ws?client=proxy");
|
||||||
|
|
||||||
let mut retry_count = 0;
|
let mut retry_count = 0;
|
||||||
|
let mut has_connected_once = false;
|
||||||
loop {
|
loop {
|
||||||
if *shutdown_rx.borrow() {
|
if *shutdown_rx.borrow() {
|
||||||
tracing::info!("Stub shutdown requested");
|
tracing::info!("Stub shutdown requested");
|
||||||
@@ -91,6 +92,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
tracing::info!("Successfully connected to target server");
|
tracing::info!("Successfully connected to target server");
|
||||||
let (mut write, mut read) = ws_stream.split();
|
let (mut write, mut read) = ws_stream.split();
|
||||||
|
|
||||||
|
if has_connected_once {
|
||||||
|
tracing::info!("Synthesizing notifications/tools/list_changed to client due to reconnect");
|
||||||
|
use tokio::io::AsyncWriteExt;
|
||||||
|
let mut stdout = tokio::io::BufWriter::new(tokio::io::stdout());
|
||||||
|
let notification = serde_json::json!({
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "notifications/tools/list_changed"
|
||||||
|
});
|
||||||
|
let payload = notification.to_string();
|
||||||
|
let _ = stdout.write_all(payload.as_bytes()).await;
|
||||||
|
let _ = stdout.write_all(b"\n").await;
|
||||||
|
let _ = stdout.flush().await;
|
||||||
|
}
|
||||||
|
has_connected_once = true;
|
||||||
|
|
||||||
let rx = msg_rx.clone();
|
let rx = msg_rx.clone();
|
||||||
let mut send_task = tokio::spawn(async move {
|
let mut send_task = tokio::spawn(async move {
|
||||||
while let Ok(msg) = rx.recv().await {
|
while let Ok(msg) = rx.recv().await {
|
||||||
|
|||||||
Reference in new issue
Block a user