@@ -45,7 +45,7 @@ pub use self::{
4545} ;
4646pub use crate :: rtc_engine:: SimulateScenario ;
4747use crate :: {
48- participant:: ConnectionQuality ,
48+ participant:: { ConnectionQuality , ParticipantState } ,
4949 prelude:: * ,
5050 registered_audio_filter_plugins,
5151 rtc_engine:: {
@@ -86,7 +86,16 @@ pub enum RoomError {
8686#[ derive( Clone , Debug ) ]
8787#[ non_exhaustive]
8888pub enum RoomEvent {
89+ /// Remote participant joined the room.
90+ ///
91+ /// This event is fired immediately after a participant joins before
92+ /// it is able to receive data messages. To send data messages in response
93+ /// to a participant joining, respond to the [`Self::ParticipantActive`] event instead.
94+ ///
8995 ParticipantConnected ( RemoteParticipant ) ,
96+ /// Remote participant is active and ready to receive data messages.
97+ ParticipantActive ( RemoteParticipant ) ,
98+ /// Remote participant disconnected from the room.
9099 ParticipantDisconnected ( RemoteParticipant ) ,
91100 LocalTrackPublished {
92101 publication : LocalTrackPublication ,
@@ -493,6 +502,7 @@ impl Room {
493502 let local_participant = LocalParticipant :: new (
494503 rtc_engine. clone ( ) ,
495504 pi. kind ( ) . into ( ) ,
505+ pi. state ( ) . into ( ) ,
496506 pi. sid . try_into ( ) . unwrap ( ) ,
497507 pi. identity . into ( ) ,
498508 pi. name ,
@@ -639,6 +649,7 @@ impl Room {
639649 let pi = pi. clone ( ) ;
640650 inner. create_participant (
641651 pi. kind ( ) . into ( ) ,
652+ pi. state ( ) . into ( ) ,
642653 pi. sid . try_into ( ) . unwrap ( ) ,
643654 pi. identity . into ( ) ,
644655 pi. name ,
@@ -976,14 +987,19 @@ impl RoomSession {
976987 // disconnected
977988 }
978989 } else if let Some ( remote_participant) = remote_participant {
990+ let already_active = remote_participant. is_active ( ) ;
979991 remote_participant. update_info ( pi. clone ( ) ) ;
992+ if !already_active && remote_participant. is_active ( ) {
993+ self . dispatcher . dispatch ( & RoomEvent :: ParticipantActive ( remote_participant. clone ( ) ) ) ;
994+ }
980995 participants. push ( Participant :: Remote ( remote_participant) ) ;
981996 } else {
982997 // Create a new participant
983998 let remote_participant = {
984999 let pi = pi. clone ( ) ;
9851000 self . create_participant (
9861001 pi. kind ( ) . into ( ) ,
1002+ pi. state ( ) . into ( ) ,
9871003 pi. sid . try_into ( ) . unwrap ( ) ,
9881004 pi. identity . into ( ) ,
9891005 pi. name ,
@@ -1547,6 +1563,7 @@ impl RoomSession {
15471563 fn create_participant (
15481564 self : & Arc < Self > ,
15491565 kind : ParticipantKind ,
1566+ state : ParticipantState ,
15501567 sid : ParticipantSid ,
15511568 identity : ParticipantIdentity ,
15521569 name : String ,
@@ -1556,6 +1573,7 @@ impl RoomSession {
15561573 let participant = RemoteParticipant :: new (
15571574 self . rtc_engine . clone ( ) ,
15581575 kind,
1576+ state,
15591577 sid. clone ( ) ,
15601578 identity. clone ( ) ,
15611579 name,
0 commit comments