This commit is contained in:
sam 2024-02-23 22:04:32 +01:00
parent 18b644d24b
commit b2c3a521e9
8 changed files with 115 additions and 9 deletions

View file

@ -27,3 +27,5 @@ base64 = "0.21.7"
sha256 = "1.5.0"
reqwest = { version = "0.11.23", features = ["json", "gzip", "brotli", "multipart"] }
chrono = "0.4.31"
futures = "0.3.30"
tokio-tungstenite = { version = "0.21.0", features = ["rustls"] }

View file

@ -2,6 +2,7 @@ mod account;
mod auth;
mod node;
mod proxy;
mod ws;
use std::sync::Arc;

View file

@ -0,0 +1,23 @@
use std::sync::Arc;
use axum::{extract::{ws::WebSocket, WebSocketUpgrade}, response::Response, Extension};
use futures::{
stream::{SplitSink, SplitStream, StreamExt},
SinkExt,
};
use crate::{app_state::AppState, model::account::Account};
pub async fn handler(ws: WebSocketUpgrade, Extension(state): Extension<Arc<AppState>>) -> Response {
ws.on_upgrade(|socket| handle_socket(state, socket))
}
struct SocketState {
user: Option<Account>,
}
async fn handle_socket(app_state: Arc<AppState>, socket: WebSocket) {
let (sender, receiver) = socket.split();
}