pub struct Reply { /* private fields */ }Expand description
What a flavor said during one crate::shard::ShardLogic::observe.
Implementations§
Source§impl Reply
impl Reply
Sourcepub fn say(&mut self, to: ConnectionId, text: &str)
pub fn say(&mut self, to: ConnectionId, text: &str)
Tell a connection something, in the server’s own name.
Sourcepub fn refuse(&mut self, to: ConnectionId, reason: &str)
pub fn refuse(&mut self, to: ConnectionId, reason: &str)
Refuse, visibly.
The point is that the client learns something happened. A flavor that stays silent leaves the user pressing a button that does nothing, which is the state this type exists to end.
Sourcepub fn relay(&mut self, from: ConnectionId, to: Audience, text: &str)
pub fn relay(&mut self, from: ConnectionId, to: Audience, text: &str)
Deliver text to to, attributed to from.
The answer to a crate::shard::VoiceEvent::Said a flavor is willing to
carry out, and the one place a client’s own words reach other clients.
The flavor stays in charge of the audience: relaying somewhere other than
where the message was aimed is a rewrite, not a workaround.
Two rules the shard applies when it expands this, both borrowed from elsewhere in the model rather than invented here:
- The sender never receives its own message.
- A recipient that cannot see
fromis skipped. That is the audio coupling rule - a receiver must see the sender - applied to text, and naming a session the recipient does not hold would break the view invariants anyway. UseReply::announcefor something everyone should read whoever said it.
Sourcepub fn announce(&mut self, to: Audience, text: &str)
pub fn announce(&mut self, to: Audience, text: &str)
Deliver text to to, in the server’s own name.
Reply::say addressed to a group: no actor, so no recipient is skipped
for not seeing one.
Sourcepub fn switch(&mut self, connection: ConnectionId, to: ShardId)
pub fn switch(&mut self, connection: ConnectionId, to: ShardId)
Hand a connection to another shard.
Not a disconnect followed by a connect: the source hands over the view the client still holds and the destination plans one transition from it. What the flavor said in the same breath is delivered first, so a farewell reaches the socket before the move is asked for.
pub fn is_empty(&self) -> bool
Sourcepub fn drain(&mut self) -> BTreeMap<ConnectionId, Vec<Word>>
pub fn drain(&mut self) -> BTreeMap<ConnectionId, Vec<Word>>
What was said, per connection, in the order it was said. Empties the reply.
Sourcepub fn drain_spoken(&mut self) -> Vec<Spoken>
pub fn drain_spoken(&mut self) -> Vec<Spoken>
What was addressed to an audience, in the order it was said. Empties the reply.
Sourcepub fn drain_effects(&mut self) -> Vec<Effect>
pub fn drain_effects(&mut self) -> Vec<Effect>
What the flavor asked the runtime for, in the order it asked. Empties the reply.