Init
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use crate::models::user::Model as User;
|
||||
use axum::extract::ws::Message;
|
||||
use parking_lot::RwLock;
|
||||
use std::collections::HashMap;
|
||||
use tokio::sync::mpsc;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub mod handlers;
|
||||
@@ -16,6 +18,7 @@ pub struct GatewayManager {
|
||||
pub struct GatewayClient {
|
||||
user: User,
|
||||
connection_id: Uuid,
|
||||
sender: mpsc::UnboundedSender<Message>,
|
||||
}
|
||||
|
||||
impl GatewayManager {
|
||||
@@ -37,11 +40,12 @@ impl GatewayManager {
|
||||
}
|
||||
|
||||
impl GatewayClient {
|
||||
pub fn new(user: User) -> Self {
|
||||
pub fn new(user: User, sender: mpsc::UnboundedSender<Message>) -> Self {
|
||||
let connection_id = Uuid::new_v4();
|
||||
Self {
|
||||
user,
|
||||
connection_id,
|
||||
sender,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +53,15 @@ impl GatewayClient {
|
||||
|
||||
async fn on_disconnect(&self) {}
|
||||
|
||||
async fn on_message(&self) {}
|
||||
async fn on_message(&self, message: Message) {
|
||||
match message {
|
||||
Message::Binary(content) => {}
|
||||
Message::Text(content) => {
|
||||
tracing::info!("Received text message: {}", content);
|
||||
}
|
||||
Message::Ping(_) => {}
|
||||
Message::Pong(_) => {}
|
||||
Message::Close(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user