[−][src]Function skyway_webrtc_gateway_api::media::listen_events
pub async fn listen_events<'a>(
media_connection_id: MediaConnectionId,
__arg1: Sender<MediaConnectionEventEnum>
) -> Result<(), Error>
Request status of MediaConnection
This function keep listening events with GET /media/connections/{media_connection_id}/events until it receives a CLOSE event or an Error event. If it receives timeout, it ignores the event and listen events again.
Examples
use futures::channel::mpsc; use futures::future::{self, *}; use futures::stream::*; use futures::*; use skyway_webrtc_gateway_api::media::{MediaConnectionEventEnum, listen_events}; use skyway_webrtc_gateway_api::prelude::MediaConnectionId; async fn example() { let media_connection_id = MediaConnectionId::new("mc-example"); let (mc_event_notifier, mc_event_observer) = mpsc::channel::<MediaConnectionEventEnum>(0); let mc_event_observer = mc_event_observer.for_each(|event| async move { // Do something }); let events_fut = listen_events(media_connection_id, mc_event_notifier); let _ = join!(mc_event_observer, events_fut); }