Leave room when Room entity is dropped

This commit is contained in:
Antonio Scandurra 2022-09-26 14:27:52 +02:00
parent 573086eed2
commit e55e7e4844
6 changed files with 89 additions and 20 deletions

View file

@ -153,6 +153,7 @@ impl Server {
.add_request_handler(Server::ping)
.add_request_handler(Server::create_room)
.add_request_handler(Server::join_room)
.add_message_handler(Server::leave_room)
.add_request_handler(Server::call)
.add_message_handler(Server::decline_call)
.add_request_handler(Server::register_project)
@ -627,6 +628,14 @@ impl Server {
Ok(())
}
async fn leave_room(self: Arc<Server>, message: TypedEnvelope<proto::LeaveRoom>) -> Result<()> {
let room_id = message.payload.id;
let mut store = self.store().await;
let room = store.leave_room(room_id, message.sender_id)?;
self.room_updated(room);
Ok(())
}
async fn call(
self: Arc<Server>,
request: TypedEnvelope<proto::Call>,