pub struct Connection { /* private fields */ }Expand description
One member’s open socket. The caller writes Connection::next_outgoing
messages to the wire and calls Connection::deliver with what it reads.
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn next_outgoing(&mut self) -> Option<Vec<u8>>
pub async fn next_outgoing(&mut self) -> Option<Vec<u8>>
The next message the room wants written to this socket, or None once
the connection is closed.
Sourcepub async fn deliver(&self, message: &[u8]) -> Result<(), RealtimeError>
pub async fn deliver(&self, message: &[u8]) -> Result<(), RealtimeError>
Feeds a message received from the socket to RoomHandler::on_message.
§Errors
RealtimeError::NotAMember if this member has already left, or has
reconnected on a newer socket since (so a late or forged frame is
dropped), else any error the handler returns.
§Panics
Panics if the room registry lock is poisoned.
Sourcepub async fn close(self) -> Result<(), RealtimeError>
pub async fn close(self) -> Result<(), RealtimeError>
Ends the membership: removes the socket and runs
RoomHandler::on_leave.
A socket this member has already replaced by reconnecting no longer owns the room’s entry for that id, so this leaves the live socket wired: the stale close must not unregister it, empty the room, or abort the alarm a live member set.
§Errors
Propagates any error the handler’s on_leave returns.
§Panics
Panics if the room registry lock is poisoned.