MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / register

Method register

crates/openshell-server/src/supervisor_session.rs:109–136  ·  view source on GitHub ↗

Register a live supervisor session for the given sandbox. If a previous session exists for the same sandbox, its shutdown signal is fired so the old session task exits promptly. Returns `true` iff a previous session was superseded.

(
        &self,
        sandbox_id: String,
        session_id: String,
        tx: mpsc::Sender<GatewayMessage>,
        shutdown: oneshot::Sender<()>,
    )

Source from the content-addressed store, hash-verified

107 /// is fired so the old session task exits promptly. Returns `true` iff a
108 /// previous session was superseded.
109 pub fn register(
110 &self,
111 sandbox_id: String,
112 session_id: String,
113 tx: mpsc::Sender<GatewayMessage>,
114 shutdown: oneshot::Sender<()>,
115 ) -> bool {
116 let mut sessions = self.sessions.lock().unwrap();
117 let previous = sessions.remove(&sandbox_id);
118 sessions.insert(
119 sandbox_id.clone(),
120 LiveSession {
121 sandbox_id,
122 session_id,
123 tx,
124 shutdown,
125 connected_at: Instant::now(),
126 },
127 );
128 match previous {
129 Some(prev) => {
130 // Best-effort — the old task may have already exited.
131 let _ = prev.shutdown.send(());
132 true
133 }
134 None => false,
135 }
136 }
137
138 /// Report whether a live supervisor session is registered for a sandbox.
139 ///

Calls 1

removeMethod · 0.45