pub struct Client {
pub id: usize,
pub stream: ClientStream,
pub map: Arc<Mutex<HashMap<String, ClientMapValue>>>,
pub plugins_manager: PluginsManagerType,
}
Expand description
Client struct
Fields
id: usize
ID of the client
stream: ClientStream
Connection stream of the client
map: Arc<Mutex<HashMap<String, ClientMapValue>>>
Custom Client Map
plugins_manager: PluginsManagerType
Plugins Manager
Implementations
sourceimpl Client
impl Client
sourcepub fn new_websocket(stream: TcpStream, id: usize) -> Result<Self>
pub fn new_websocket(stream: TcpStream, id: usize) -> Result<Self>
Create a new WebSocket Client instance
sourcepub fn send<S>(&self, msg: S) -> Result<()>where
S: ToString,
S: Display,
pub fn send<S>(&self, msg: S) -> Result<()>where
S: ToString,
S: Display,
Send a message to the client
sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Returns the socket address of the remote peer of this connection.
sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
sourcepub fn insert_key<S>(
&self,
key: S,
value: ClientMapValue
) -> Option<ClientMapValue>where
S: ToString,
pub fn insert_key<S>(
&self,
key: S,
value: ClientMapValue
) -> Option<ClientMapValue>where
S: ToString,
Inserts a key-value pair into the map.
sourcepub fn get_value<S>(&self, key: S) -> Option<ClientMapValue>where
S: ToString,
pub fn get_value<S>(&self, key: S) -> Option<ClientMapValue>where
S: ToString,
Returns the value from the key.
sourcepub fn delete_key<S>(&self, key: S) -> Option<ClientMapValue>where
S: ToString,
pub fn delete_key<S>(&self, key: S) -> Option<ClientMapValue>where
S: ToString,
Delete key from the map.
pub async fn run_events(
&self,
event_type: EventType,
event_data: EventData
) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more