Struct caesar_core::relay::client::Client
source · pub struct Client {
sender: Arc<Mutex<SplitSink<WebSocket, Message>>>,
room_id: Option<String>,
}Expand description
Struct representing a WebSocket client.
This struct contains a WebSocket sender and an optional room ID. The sender is used to send messages to the WebSocket connection, while the room ID is used to identify the client’s room.
Fields§
§sender: Arc<Mutex<SplitSink<WebSocket, Message>>>The WebSocket sender for sending messages.
room_id: Option<String>The optional room ID of the client.
This is used to identify the client’s room.
Implementations§
source§impl Client
impl Client
sourceasync fn send_packet(
&self,
sender: Arc<Mutex<SplitSink<WebSocket, Message>>>,
packet: ResponsePacket
)
async fn send_packet( &self, sender: Arc<Mutex<SplitSink<WebSocket, Message>>>, packet: ResponsePacket )
sourceasync fn send_error_packet(
&self,
sender: Arc<Mutex<SplitSink<WebSocket, Message>>>,
message: String
)
async fn send_error_packet( &self, sender: Arc<Mutex<SplitSink<WebSocket, Message>>>, message: String )
sourceasync fn handle_create_room(
&mut self,
server: &RwLock<AppState>,
id: Option<String>
)
async fn handle_create_room( &mut self, server: &RwLock<AppState>, id: Option<String> )
sourceasync fn handle_join_room(&mut self, server: &RwLock<AppState>, room_id: String)
async fn handle_join_room(&mut self, server: &RwLock<AppState>, room_id: String)
sourceasync fn handle_leave_room(&mut self, server: &RwLock<AppState>)
async fn handle_leave_room(&mut self, server: &RwLock<AppState>)
sourcepub async fn handle_message(
&mut self,
server: &RwLock<AppState>,
message: Message
)
pub async fn handle_message( &mut self, server: &RwLock<AppState>, message: Message )
Handles incoming messages from the client.
This function interprets the incoming message and performs the corresponding action.
§Arguments
server- A RwLock guard containing the state of the server.message- The incoming message from the client.
pub async fn handle_close(&mut self, server: &RwLock<AppState>)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more