Write input data (base64 encoded) to a terminal session.
(&mut self, session_id: &str, data_b64: &str)
| 183 | let _ = tx.send(TerminalEvent::Started { session_id: sid }).await; |
| 184 | }); |
| 185 | } |
| 186 | |
| 187 | /// Write input data (base64 encoded) to a terminal session. |
| 188 | pub fn write_input(&mut self, session_id: &str, data_b64: &str) { |
| 189 | let session = match self.sessions.get_mut(session_id) { |
| 190 | Some(s) => s, |
| 191 | None => { |
| 192 | tracing::warn!("Terminal session {session_id} not found for input"); |
| 193 | return; |
| 194 | } |
| 195 | }; |
| 196 | |
| 197 | let data = match BASE64.decode(data_b64) { |
| 198 | Ok(d) => d, |
| 199 | Err(e) => { |
| 200 | tracing::warn!("Invalid base64 terminal input: {e}"); |
| 201 | return; |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | if let Err(e) = session.writer.write_all(&data) { |
| 206 | tracing::error!("Failed to write to PTY {session_id}: {e}"); |
| 207 | // Session may be dead, clean up |
| 208 | self.close(session_id); |
| 209 | } |
| 210 | } |
no test coverage detected