mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
fbb3a30953
I'd like WireApi to go away (when chat is removed) and WebSockets is still responses API just over a different transport.
23 lines
556 B
Rust
23 lines
556 B
Rust
use std::sync::Arc;
|
|
use std::sync::atomic::AtomicBool;
|
|
use std::sync::atomic::Ordering;
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct TransportManager {
|
|
disable_websockets: Arc<AtomicBool>,
|
|
}
|
|
|
|
impl TransportManager {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub fn disable_websockets(&self) -> bool {
|
|
self.disable_websockets.load(Ordering::Relaxed)
|
|
}
|
|
|
|
pub fn activate_http_fallback(&self, websocket_enabled: bool) -> bool {
|
|
websocket_enabled && !self.disable_websockets.swap(true, Ordering::Relaxed)
|
|
}
|
|
}
|