feat: rtc peer connection offer

This commit is contained in:
Ahmet Kaan Gümüş 2025-04-11 04:58:16 +03:00
parent 7434d131c4
commit 0aa65f0f60
17 changed files with 389 additions and 59 deletions

36
server/src/signal.rs Normal file
View file

@ -0,0 +1,36 @@
use std::sync::{Arc, LazyLock, RwLock};
use axum::{
Json, Router,
http::StatusCode,
response::IntoResponse,
routing::{get, post},
};
use axum_macros::debug_handler;
use protocol::Signal;
use tokio::net::TcpListener;
static SIGNALS: LazyLock<Arc<RwLock<Vec<Signal>>>> =
LazyLock::new(|| Arc::new(RwLock::new(vec![])));
pub async fn start_signalling() {
let route = route();
let listener = TcpListener::bind("0.0.0.0:4546").await.unwrap();
axum::serve(listener, route).await.unwrap();
}
fn route() -> Router {
Router::new()
.route("/alive", get(alive))
.route("/", post(signal))
}
async fn alive() -> impl IntoResponse {
StatusCode::OK
}
#[debug_handler]
async fn signal(Json(signal): Json<Signal>) -> impl IntoResponse {
SIGNALS.write().unwrap().push(signal);
StatusCode::OK
}