pub struct Chat { /* private fields */ }Expand description
This member’s chat in a room, and every other member’s.
Dropping it withdraws this member’s chat and stops the readers. Neither keeps the room joined: the readers stop once its last handle drops.
Implementations§
Source§impl Chat
impl Chat
Sourcepub fn new(room: &Room) -> Result<Self>
pub fn new(room: &Room) -> Result<Self>
Publishes this member’s chat into room and starts reading the others.
Keeps one reader per member that publishes NAME, as the
membership changes. A reader follows the member through
Room::subscriptions, and a new subscription replays the member’s
window without repeating the messages delivered already.
§Errors
Fails if the chat broadcast cannot be published.
§Panics
Panics when called outside a Tokio runtime.
Sourcepub fn send(&self, text: impl Into<String>)
pub fn send(&self, text: impl Into<String>)
Sends text to the room, unless the writer is backed up.
Other members’ copies come back through recv, this
member’s own do not.
Sourcepub fn try_recv(&mut self) -> Option<Message>
pub fn try_recv(&mut self) -> Option<Message>
Returns the next received message, if one is waiting.