mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
ws: include "type" field in RtcOffer and RtcAnswer
This commit is contained in:
parent
0789f7ec3b
commit
c37bf89650
5 changed files with 25 additions and 1 deletions
|
|
@ -30,11 +30,26 @@ pub struct OfferId(
|
|||
pub [u8; 20],
|
||||
);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RtcOfferType {
|
||||
Offer,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RtcAnswerType {
|
||||
Answer,
|
||||
}
|
||||
|
||||
/// Nested structure with SDP offer from https://www.npmjs.com/package/simple-peer
|
||||
///
|
||||
/// Created using https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct RtcOffer {
|
||||
/// Always "offer"
|
||||
#[serde(rename = "type")]
|
||||
pub t: RtcOfferType,
|
||||
pub sdp: ::serde_json::Value,
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +58,9 @@ pub struct RtcOffer {
|
|||
/// Created using https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createAnswer
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct RtcAnswer {
|
||||
/// Always "answer"
|
||||
#[serde(rename = "type")]
|
||||
pub t: RtcAnswerType,
|
||||
pub sdp: ::serde_json::Value,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,13 @@ mod tests {
|
|||
|
||||
fn rtc_offer() -> RtcOffer {
|
||||
RtcOffer {
|
||||
t: RtcOfferType::Offer,
|
||||
sdp: ::serde_json::json!({ "sdp": "test" }),
|
||||
}
|
||||
}
|
||||
fn rtc_answer() -> RtcAnswer {
|
||||
RtcAnswer {
|
||||
t: RtcAnswerType::Answer,
|
||||
sdp: ::serde_json::json!({ "sdp": "test" }),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue