scuffle_rtmp/command_messages/on_status/
mod.rs

1//! Types and functions for processing the `onStatus` command.
2//!
3//! It is not very clear if the onStatus command should be part of the NetConnection or NetStream set of commands.
4//! The legacy RTMP spec makes it look like it should be part of the NetStream commands while the enhanced-rtmp-v2 spec
5//! is very clear that it should be part of the NetConnection commands.
6//! In reality, it is used as a response message to both NetConnection and NetStream commands received from the client.
7//! This is why we have decided to put it in its own module.
8
9use nutype_enum::nutype_enum;
10use scuffle_amf0::Amf0Object;
11use scuffle_bytes_util::StringCow;
12
13use crate::command_messages::CommandResultLevel;
14
15pub mod writer;
16
17/// The `onStatus` command is used to send status information from the server to the client.
18#[derive(Debug, Clone, PartialEq, serde::Serialize)]
19#[serde(rename_all = "camelCase")]
20pub struct OnStatus<'a> {
21    /// The status code.
22    ///
23    /// Refer to the [`OnStatusCode`] enum for a list of common status codes.
24    pub code: OnStatusCode,
25    /// The description of the status update.
26    pub description: Option<StringCow<'a>>,
27    /// The level of the status update.
28    pub level: CommandResultLevel,
29    /// Any other additional information that should be sent as part of the object.
30    #[serde(flatten)]
31    pub others: Option<Amf0Object<'a>>,
32}
33
34nutype_enum! {
35    /// Common status codes used in the `onStatus` command.
36    #[derive(serde::Serialize)]
37    #[serde(transparent)]
38    pub enum OnStatusCode(&'static str) {
39        /// The `NetConnection.call()` method was not able to invoke the server-side method or command.
40        NET_CONNECTION_CALL_FAILED = "NetConnection.Call.Failed",
41        /// The application has been shut down (for example, if the application is out of memory resources
42        /// and must shut down to prevent the server from crashing) or the server has shut down.
43        NET_CONNECTION_CONNECT_APP_SHUTDOWN = "NetConnection.Connect.AppShutdown",
44        /// The connection was closed successfully.
45        NET_CONNECTION_CONNECT_CLOSED = "NetConnection.Connect.Closed",
46        /// The connection attempt failed.
47        NET_CONNECTION_CONNECT_FAILED = "NetConnection.Connect.Failed",
48        /// The client does not have permission to connect to the application.
49        NET_CONNECTION_CONNECT_REJECTED = "NetConnection.Connect.Rejected",
50        /// The connection attempt succeeded.
51        NET_CONNECTION_CONNECT_SUCCESS = "NetConnection.Connect.Success",
52        /// The server is requesting the client to reconnect.
53        NET_CONNECTION_CONNECT_RECONNECT_REQUEST = "NetConnection.Connect.ReconnectRequest",
54        /// The proxy server is not responding. See the ProxyStream class.
55        NET_CONNECTION_PROXY_NOT_RESPONDING = "NetConnection.Proxy.NotResponding",
56
57        /// Publishing has started.
58        NET_STREAM_PUBLISH_START = "NetStream.Publish.Start",
59        /// Stream was successfully deleted.
60        NET_STREAM_DELETE_STREAM_SUCCESS = "NetStream.DeleteStream.Suceess",
61    }
62}