mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 13:29:21 +00:00
Properly close connections
This commit is contained in:
parent
72eadb9422
commit
13bf916652
@ -360,9 +360,25 @@ pub fn make_user_leave_call(conv_id: &ConvID, connection: &UserWsConnection) ->
|
||||
user_ws_controller::send_to_client(connection, &UserWsMessage::no_id_message("call_closed", conv_id)?)?;
|
||||
}
|
||||
|
||||
// TODO : call main stream (sender)
|
||||
// Close main stream (sender)
|
||||
events_helper::propagate_event(&Event::CloseCallStream(&CloseCallStream {
|
||||
call_hash: gen_call_hash(&conv_id, &connection.user_id),
|
||||
peer_id: None,
|
||||
}))?;
|
||||
|
||||
// TODO : close receiver streams (other users streams)
|
||||
// Close receiver streams (other users streams)
|
||||
user_ws_controller::foreach_connection(
|
||||
|peer_conn| {
|
||||
if peer_conn.is_having_call_with_conversation(conv_id) && &peer_conn.user_id != &connection.user_id {
|
||||
events_helper::propagate_event(&Event::CloseCallStream(&CloseCallStream {
|
||||
call_hash: gen_call_hash(&conv_id, &peer_conn.user_id),
|
||||
peer_id: Some(connection.user_id.clone()),
|
||||
}))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
// Create a notification
|
||||
events_helper::propagate_event(&Event::UserLeftCall(conv_id, &connection.user_id))?;
|
||||
@ -419,7 +435,17 @@ pub fn handle_event(e: &events_helper::Event) -> Res {
|
||||
)?;
|
||||
}
|
||||
|
||||
// TODO : handle proxy disconnect => close all active calls
|
||||
// Handle proxy disconnect => close all active calls
|
||||
Event::ClosedRTCRelayWebSocket => {
|
||||
user_ws_controller::foreach_connection(|f| {
|
||||
// Close all active connections
|
||||
if let Some(call) = &f.active_call {
|
||||
make_user_leave_call(&call.conv_id, f)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})?;
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
@ -188,7 +188,13 @@ impl Handler<RTCMessages> for RtcRelayActor {
|
||||
// Send message
|
||||
RTCMessages::SendMessage(msg) => {
|
||||
match serde_json::to_string(&msg) {
|
||||
Ok(txt) => { ctx.text(txt) }
|
||||
Ok(txt) => {
|
||||
if conf().verbose_mode {
|
||||
println!("API => RTC WS : {}", txt);
|
||||
}
|
||||
|
||||
ctx.text(txt)
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to send message to RTC relay ! {:#?}", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user