pub struct DisconnectReason {
pub code: Option<u16>,
pub reason: String,
}Expand description
A real-time bidirectional streaming session.
This trait provides a unified interface for real-time voice/audio sessions across different providers (OpenAI, Gemini, etc.).
§Example
use adk_realtime::{RealtimeSession, ServerEvent};
async fn handle_session(session: &dyn RealtimeSession) -> Result<()> {
// Send audio
session.send_audio(audio_chunk).await?;
// Receive events
while let Some(event) = session.next_event().await {
match event? {
ServerEvent::AudioDelta { delta, .. } => { /* play audio */ }
ServerEvent::FunctionCallDone { name, arguments, call_id, .. } => {
// Execute tool and respond
let result = execute_tool(&name, &arguments);
session.send_tool_response(call_id, result).await?;
}
_ => {}
}
}
Ok(())
}Why a provider closed the stream, when it said.
A closed transport and a provider that deliberately hung up both reach a
polling caller as next_event() -> None, so without this they produce the
same terminal record. Distinguishing them matters: “the provider aborted an
idle session” and “the network dropped” call for different responses, and
an application that records the first as a generic stream failure sends an
operator looking for a defect that is not there.
Fields§
§code: Option<u16>The WebSocket close code, if the peer sent a close frame.
reason: StringThe peer’s stated reason. Provider text, so treat it as data.
Trait Implementations§
Source§impl Clone for DisconnectReason
impl Clone for DisconnectReason
Source§fn clone(&self) -> DisconnectReason
fn clone(&self) -> DisconnectReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more