[package]
name = "holtburger-session"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
holtburger-common = { workspace = true }
holtburger-protocol = { workspace = true }
tokio = { workspace = true, features = ["rt", "sync", "macros", "time"] }
log = { workspace = true }
thiserror = { workspace = true }
serde = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
byteorder = { workspace = true }
web-time = { workspace = true }

# Native-only: UDP socket support for the production `Session::new` path.
# Wasm32 builds use `Session::new_with_transport` with a non-UDP transport
# (e.g. `WsTransport` in Phase 2 of emit-dynamic-site), so neither tokio's
# `net` feature nor `socket2` is reachable there.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = ["net"] }
socket2 = { workspace = true }

# Wasm32-only: `gloo-timers` provides a `setTimeout`-backed Future for
# the receive loop's deadline-driven control-packet flush. `tokio::time::
# sleep` won't work on wasm32-unknown-unknown — its time driver wakes
# via `std::time::Instant::now()`, which is a hard-panic stub on this
# target ("time not implemented on this platform"). The handshake's
# CONNECT_RESPONSE wait (`ACE_HANDSHAKE_RACE_DELAY_MS = 200ms`) is the
# concrete codepath that needs this; without the swap, Phase 4 step 1's
# `start_session` panics inside the wasm bundle the moment the session
# tries to honour any pending control packet's deadline.
[target.'cfg(target_arch = "wasm32")'.dependencies]
gloo-timers = { version = "0.3", features = ["futures"] }

[dev-dependencies]
hex.workspace = true
tokio = { workspace = true, features = ["full", "macros"] }
