pub struct SseSubscriber { /* private fields */ }Expand description
SSE subscriber for OpenCode events.
Implementations§
Source§impl SseSubscriber
impl SseSubscriber
Sourcepub fn new(
base_url: String,
directory: Option<String>,
last_event_id: Arc<RwLock<Option<String>>>,
) -> Self
pub fn new( base_url: String, directory: Option<String>, last_event_id: Arc<RwLock<Option<String>>>, ) -> Self
Create a new SSE subscriber.
Sourcepub async fn subscribe_session(
&self,
session_id: &str,
opts: SseOptions,
) -> Result<SseSubscription>
pub async fn subscribe_session( &self, session_id: &str, opts: SseOptions, ) -> Result<SseSubscription>
Subscribe to events, optionally filtered by session ID.
OpenCode’s /event endpoint streams all events for the configured directory.
If session_id is provided, events will be filtered client-side to only
include events for that session.
§Errors
Returns an error if the subscription cannot be created.
Sourcepub async fn subscribe(&self, opts: SseOptions) -> Result<SseSubscription>
pub async fn subscribe(&self, opts: SseOptions) -> Result<SseSubscription>
Subscribe to all events for the configured directory.
This uses the /event endpoint which streams all events for the
directory specified via the x-opencode-directory header.
§Errors
Returns an error if the subscription cannot be created.
Sourcepub async fn subscribe_typed(&self, opts: SseOptions) -> Result<SseSubscription>
pub async fn subscribe_typed(&self, opts: SseOptions) -> Result<SseSubscription>
Subscribe to all events for the configured directory as typed Event values.
This is equivalent to Self::subscribe, but explicitly named to distinguish
it from Self::subscribe_raw.
Sourcepub async fn subscribe_global(
&self,
opts: SseOptions,
) -> Result<SseSubscription>
pub async fn subscribe_global( &self, opts: SseOptions, ) -> Result<SseSubscription>
Subscribe to global events (all directories).
This uses the /global/event endpoint which streams events from all
OpenCode instances across all directories. Events are wrapped in a
GlobalEventEnvelope with directory context.
§Errors
Returns an error if the subscription cannot be created.
Sourcepub async fn subscribe_typed_global(
&self,
opts: SseOptions,
) -> Result<SseSubscription>
pub async fn subscribe_typed_global( &self, opts: SseOptions, ) -> Result<SseSubscription>
Subscribe to global events as typed Event values (all directories).
Sourcepub async fn subscribe_raw(
&self,
opts: SseOptions,
) -> Result<RawSseSubscription>
pub async fn subscribe_raw( &self, opts: SseOptions, ) -> Result<RawSseSubscription>
Subscribe to raw JSON SSE frames from the configured directory’s /event stream.
This is intended for debugging and parity verification.
Sourcepub async fn session_event_router(
&self,
opts: SessionEventRouterOptions,
) -> Result<SessionEventRouter>
pub async fn session_event_router( &self, opts: SessionEventRouterOptions, ) -> Result<SessionEventRouter>
Create a session event router with one upstream /event subscription.
Trait Implementations§
Source§impl Clone for SseSubscriber
impl Clone for SseSubscriber
Source§fn clone(&self) -> SseSubscriber
fn clone(&self) -> SseSubscriber
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more