Request life cycle
What happens between a client sending a byte and a plugin seeing a message, and back. This is a map for reading the code; follow the file names for detail.
A Janus API request
- A listener accepts it. HTTP (
janus/src/http_listener.rs, on hyper), WebSockets (ws_listener.rs, tungstenite), or the MQTT, RabbitMQ, Unix-socket and nanomsg listeners. Each does only what its C transport does: framing, routing the path to ids, CORS, ACLs, replying. - The core dispatches it.
janus_core::apivalidates the JSON the wayjanus.cdoes, in the same order (so the same error code comes out for the same mistake), finds the session and handle, and checksapisecretor the token. - A plugin handles it. For
message, the core callsPlugin::handle_messagewith the body and JSEP. The plugin answers at once (the reply becomessuccess) or says it will answer later, and the core sendsack. Later answers go throughPluginCallbacks::push_event. - The reply goes back to the transport the session came from; for HTTP it waits in the session's queue until a long poll takes it.
Replies and events keep the order the C server gives them: the ack of a message always precedes its event (PARITY_LOG.md has the decision).
Media
- The JSEP offer and answer pass through the core, which merges them with the plugin's SDP as
sdp.cdoes and starts an ICE agent for the handle. - The binary binds the UDP sockets (
janus/src/ice_socket.rs) and feeds packets to the sans-IOjanus-iceagent, thenjanus-dtlsfor the handshake, which yields the SRTP keys forjanus-srtp. - Decrypted RTP and RTCP go to the plugin through
Plugin::incoming_rtpandincoming_rtcp. A plugin does not send packets. It returns a list of relay decisions, each naming a target handle and a packet (ADR-0005); the core performs them, protects them and sends them. - Data channels run SCTP over the same DTLS (
janus-sctp), and plugins seeincoming_dataand callrelay_data.
Why this shape
Sockets live in one place, so every state machine can be tested with plain byte arrays, and the replay harness can drive the whole server over HTTP. The cost is that some paths cross several layers; the C line numbers in comments are how to find the counterpart in the original.