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