@@ -51,8 +51,6 @@ impl IntoResponse for SignalingError {
5151 }
5252}
5353
54- /// Join a room / create participant
55- /// POST /api/v1/rooms/{roomId}
5654#[ axum:: debug_handler]
5755async fn join_room (
5856 Path ( room_id) : Path < ExternalRoomId > ,
@@ -78,23 +76,33 @@ async fn join_room(
7876 . await
7977 . map_err ( |_| controller:: ControllerError :: ServiceUnavailable ) ??;
8078
79+ // TODO: remove hardcoded URI
8180 let location_url = format ! (
82- "/api/v1/rooms/{}/participants/{}" ,
83- & room_id, & participant_id
81+ "http://localhost:3000 /api/v1/rooms/{}/participants/{}" ,
82+ & room_id. external , & participant_id
8483 ) ;
8584 let mut response_headers = HeaderMap :: new ( ) ;
8685 response_headers. insert ( LOCATION , location_url. parse ( ) . unwrap ( ) ) ;
8786 Ok ( ( StatusCode :: CREATED , response_headers, answer_sdp) )
8887}
8988
90- /// Leave a room / delete participant
91- /// DELETE /api/v1/rooms/{roomId}/participants/{participantId}
9289#[ axum:: debug_handler]
9390async fn leave_room (
9491 Path ( ( room_id, participant_id) ) : Path < ( ExternalRoomId , ParticipantId ) > ,
95- State ( _controller ) : State < controller:: ControllerHandle > ,
92+ State ( con ) : State < controller:: ControllerHandle > ,
9693) -> Result < impl IntoResponse , SignalingError > {
97- // TODO: terminate participant session
94+ let room_id = RoomId :: new ( room_id) ;
95+ let room_id = Arc :: new ( room_id) ;
96+ let participant_id = Arc :: new ( participant_id) ;
97+
98+ // If controller has exited, there's no dangling participants and rooms
99+ let _ = con
100+ . send_high ( controller:: ControllerMessage :: RemoveParticipant (
101+ room_id,
102+ participant_id,
103+ ) )
104+ . await ;
105+
98106 Ok ( StatusCode :: NO_CONTENT )
99107}
100108
0 commit comments