JoinVoice events
This commit is contained in:
@@ -43,6 +43,11 @@ pub enum ClientMethod {
|
|||||||
channel_id: String,
|
channel_id: String,
|
||||||
message_id: String,
|
message_id: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
JoinVoice {
|
||||||
|
channel_id: String,
|
||||||
|
pin: u64,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -87,6 +92,10 @@ pub enum ServerMethod {
|
|||||||
message_id: String,
|
message_id: String,
|
||||||
channel_id: String,
|
channel_id: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
JoinVoice {
|
||||||
|
channel_id: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn read_loop(
|
pub async fn read_loop(
|
||||||
@@ -152,6 +161,22 @@ pub async fn read_loop(
|
|||||||
ServerMethod::GetUsers { pubkeys } => {
|
ServerMethod::GetUsers { pubkeys } => {
|
||||||
user::get_users(server, verifying_key, socket, pubkeys).await?;
|
user::get_users(server, verifying_key, socket, pubkeys).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerMethod::JoinVoice { channel_id } => {
|
||||||
|
let pin = rand::random();
|
||||||
|
|
||||||
|
server
|
||||||
|
.voice_pins
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.insert(pin, (verifying_key, channel_id.clone()));
|
||||||
|
|
||||||
|
send_socket(
|
||||||
|
&mut *socket.lock().await,
|
||||||
|
&ClientMethod::JoinVoice { channel_id, pin },
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_lock = socket.lock().await;
|
socket_lock = socket.lock().await;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ pub struct Server {
|
|||||||
pub key: SigningKey,
|
pub key: SigningKey,
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
pub clients: Mutex<HashMap<VerifyingKey, Arc<UserConnections>>>,
|
pub clients: Mutex<HashMap<VerifyingKey, Arc<UserConnections>>>,
|
||||||
|
pub voice_pins: Mutex<HashMap<u64, (VerifyingKey, String)>>,
|
||||||
pub message_store: MessageStore,
|
pub message_store: MessageStore,
|
||||||
pub user_store: UserMetaStore,
|
pub user_store: UserMetaStore,
|
||||||
}
|
}
|
||||||
@@ -38,6 +39,7 @@ impl Server {
|
|||||||
key: crate::crypto::get().await?,
|
key: crate::crypto::get().await?,
|
||||||
config: Config::get().await?,
|
config: Config::get().await?,
|
||||||
clients: Mutex::new(HashMap::new()),
|
clients: Mutex::new(HashMap::new()),
|
||||||
|
voice_pins: Mutex::new(HashMap::new()),
|
||||||
message_store: MessageStore::new(PathBuf::from("messages"))?,
|
message_store: MessageStore::new(PathBuf::from("messages"))?,
|
||||||
user_store: UserMetaStore::new(PathBuf::from("users.db"))?,
|
user_store: UserMetaStore::new(PathBuf::from("users.db"))?,
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user