mpc_manager/service/notification.rs
1//! Notification
2//!
3//! This module contains the notification enum that is used to send
4//! notifications to multiple clients.
5
6use crate::state::{group::GroupId, session::SessionId, ClientId};
7use serde_json::Value;
8
9/// Notification sent by the server to multiple connected clients.
10#[derive(Debug)]
11pub enum Notification {
12 /// Send to all the clients in a group.
13 Group {
14 /// The group identifier.
15 group_id: GroupId,
16 /// Ignore these clients.
17 filter: Vec<ClientId>,
18 /// The method name.
19 method: String,
20 /// Message to send to the clients.
21 message: Value,
22 },
23
24 /// Sends to all clients in a session.
25 Session {
26 /// The group identifier.
27 group_id: GroupId,
28 /// The session identifier.
29 session_id: SessionId,
30 /// Ignore these clients.
31 filter: Vec<ClientId>,
32 /// The method name.
33 method: String,
34 /// Message to send to the clients.
35 message: Value,
36 },
37
38 /// Relay messages to specific clients.
39 ///
40 /// Used for relaying peer to peer messages.
41 Relay {
42 /// The method name.
43 method: String,
44 /// Mapping of client connection identifiers to messages.
45 messages: Vec<(ClientId, Value)>,
46 },
47}