pub struct RtmpConnection<S = BoxStream> { /* private fields */ }tokio only.Expand description
One accepted RTMP connection: a stream (an erased BoxStream by
default) driving a ServerSession.
next_events is the whole surface: read a chunk,
drive the session, write the reply, return the events.
Implementations§
Source§impl RtmpConnection<BoxStream>
impl RtmpConnection<BoxStream>
Sourcepub fn from_stream<S>(stream: S, config: RtmpServerConfig) -> Selfwhere
S: RtmpStream + 'static,
pub fn from_stream<S>(stream: S, config: RtmpServerConfig) -> Selfwhere
S: RtmpStream + 'static,
Wraps an already-connected stream, erasing its type, and drives the
session config carries: the constructor AsyncRtmpServer::accept
uses, so one RtmpConnection names the connection whatever the
transport. RtmpServerConfig::new carries a fresh session (a
RtmpServerConfig) and the caller’s Timeouts.
Sourcepub async fn next_events(&mut self) -> Result<Option<Vec<ServerEvent>>>
pub async fn next_events(&mut self) -> Result<Option<Vec<ServerEvent>>>
Reads one chunk from the socket, drives ServerSession::handle_data,
writes the reply bytes back (all of them), and returns the resulting
events.
Returns Ok(None) when the connection is finished: the peer closed
the socket (clean EOF), or the most recent batch of events included
ServerEvent::Eof (so the caller sees that final batch once, then
None on the next call). Once a call returns None, every
subsequent call also returns None without reading the socket again.
Cancel-safe: dropping the future at any await point loses neither a reply
byte nor an event (the reply sits in the framed write buffer, the events
in self, until a later call delivers them).
§Errors
An io::Error from the underlying socket read/write, or a mapped
RtmpError (kind io::ErrorKind::InvalidData)
from ServerSession::handle_data. On an RtmpError the session is
unrecoverable (per handle_data’s own doc): this connection is torn
down immediately — marked closed and not driven further, even if the
caller keeps calling next_events. A deadline expiry
(Timeouts) is io::ErrorKind::TimedOut and closes the
connection too.