refactor: ♻️ signal
This commit is contained in:
parent
ffc802eb59
commit
85fb4fb2af
3 changed files with 74 additions and 40 deletions
|
@ -1,19 +1,35 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Signal {
|
||||
pub username: String,
|
||||
pub time: DateTime<Utc>,
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum SignalType {
|
||||
Auth,
|
||||
Offer,
|
||||
Answer,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct RTCSessionOffer {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Signal {
|
||||
pub username: String,
|
||||
pub rtc_session_offer: String,
|
||||
pub signal_type: SignalType,
|
||||
pub data: String,
|
||||
time: DateTime<Utc>,
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct RTCSessionAnswer {
|
||||
pub username: String,
|
||||
pub rtc_session_offer: String,
|
||||
|
||||
impl Signal {
|
||||
pub fn new(username: &String, signal_type: &SignalType, data: &String) -> Signal {
|
||||
let username = username.to_owned();
|
||||
let signal_type = *signal_type;
|
||||
let data = data.to_owned();
|
||||
Signal {
|
||||
username,
|
||||
signal_type,
|
||||
data,
|
||||
time: DateTime::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_time(&self) -> DateTime<Utc> {
|
||||
self.time
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue