harlanc / xiu

A simple,high performance and secure live media server in pure Rust (RTMP[cluster]/RTSP/WebRTC[whip/whep]/HTTP-FLV/HLS).🦀
https://www.rustxiu.com
MIT License
1.6k stars 168 forks source link

feat: abstract streamhub message notifications #132

Closed vaptu closed 1 month ago

vaptu commented 1 month ago

example

let notifier: Option<Arc<dyn Notifier>> = if let Some(httpnotifier) = &self.cfg.httpnotify {
    if !httpnotifier.enabled {
    None
    } else {
    // Or a custom-defined Notifier
    Some(Arc::new(HttpNotifier::new(
        httpnotifier.on_publish.clone(),
        httpnotifier.on_unpublish.clone(),
        httpnotifier.on_play.clone(),
        httpnotifier.on_stop.clone(),
    )))
    }
} else {
    None
};

The Notify trait can be customized by the users of the library.

harlanc commented 1 month ago

Thank you.