-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sse::Sender::send take an id arg
- Loading branch information
1 parent
0549ecb
commit ed63830
Showing
3 changed files
with
25 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// An SSE message sender. | ||
#[derive(Debug)] | ||
pub struct Sender { | ||
sender: async_sse::Sender, | ||
} | ||
|
||
impl Sender { | ||
/// Create a new instance of `Sender`. | ||
pub(crate) fn new(sender: async_sse::Sender) -> Self { | ||
Self { sender } | ||
} | ||
|
||
/// Send data from the SSE channel. | ||
/// | ||
/// Each message constists of a "name" and "data". | ||
pub async fn send(&self, name: &str, data: impl AsRef<str>, id: Option<&str>) { | ||
self.sender.send(name, data.as_ref().as_bytes(), id).await; | ||
} | ||
} |