Commit f4bc13bf authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

Define basic protocol data structures between server, web app and publisher app

parent fa31d565
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4,3 +4,8 @@ version = "0.1.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
edition = "2018"
license = "MIT"

[dependencies]
serde = "1"
uuid = { version = "0.8", features = ["serde"] }
 

common/src/api.rs

0 → 100644
+19 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use serde::{Deserialize, Serialize};

/// Response of the `rooms` endpoint.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub struct Rooms(Vec<Room>);

/// Information for one `Room
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub struct Room {
    id: uuid::Uuid,
    name: String,
    description: Option<String>,
}
+4 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

pub mod api;
pub mod publisher;
pub mod subscriber;
+48 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use serde::{Deserialize, Serialize};

/// Messages sent from the publisher to the server.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum PublisherMessage {
    CreateRoom {
        name: String,
        description: Option<String>,
    },
    DeleteRoom,
    Ice {
        candidate: String,
        #[serde(rename = "sdpMLineIndex")]
        sdp_mline_index: u32,
    },
    Sdp {
        #[serde(rename = "type")]
        type_: String,
        sdp: String,
    },
}

/// Messages sent from the the server to the publisher.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ServerMessage {
    Error {
        message: String,
    },
    RoomCreated {
        id: uuid::Uuid,
    },
    Ice {
        candidate: String,
        #[serde(rename = "sdpMLineIndex")]
        sdp_mline_index: u32,
    },
    Sdp {
        #[serde(rename = "type")]
        type_: String,
        sdp: String,
    },
}
+44 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use serde::{Deserialize, Serialize};

/// Messages sent from the subscriber to the server.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum SubscriberMessage {
    JoinRoom {
        id: uuid::Uuid,
    },
    LeaveRoom,
    Ice {
        candidate: String,
        #[serde(rename = "sdpMLineIndex")]
        sdp_mline_index: u32,
    },
    Sdp {
        #[serde(rename = "type")]
        type_: String,
        sdp: String,
    },
}

/// Messages sent from the the server to the subscriber.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ServerMessage {
    Error {
        message: String,
    },
    Ice {
        candidate: String,
        #[serde(rename = "sdpMLineIndex")]
        sdp_mline_index: u32,
    },
    Sdp {
        #[serde(rename = "type")]
        type_: String,
        sdp: String,
    },
}