pub struct Websocket {
pub send: Option<Sender<Message>>,
pub key: String,
pub deflate: DeflateConfig,
/* private fields */
}Fields§
§send: Option<Sender<Message>>§key: String§deflate: DeflateConfigImplementations§
Source§impl Websocket
impl Websocket
pub fn http(request: Request, response: Response) -> Self
pub fn new(request: Request, response: Response) -> Self
pub fn send(&self, data: &JsonValue)
pub fn send_binary(&self, data: &[u8])
pub fn ping(&self, payload: &[u8])
pub fn close(&self, code: CloseCode, reason: &str)
pub fn online_users(&self) -> usize
pub fn is_connected(&self) -> bool
pub fn handle(&mut self) -> Result<(), HttpError>
Trait Implementations§
Source§impl Handler for Websocket
impl Handler for Websocket
Source§fn on_request(&mut self, _request: Request, _response: &mut Response)
fn on_request(&mut self, _request: Request, _response: &mut Response)
请求 处理
fn on_frame(&mut self) -> Result<(), HttpError>
Source§fn on_options(&mut self, response: &mut Response)
fn on_options(&mut self, response: &mut Response)
预检请求处理 OPTIONS
Source§fn on_response(&mut self, response: &mut Response)
fn on_response(&mut self, response: &mut Response)
响应 处理
Source§fn on_shutdown(&mut self)
fn on_shutdown(&mut self)
关机监听
Auto Trait Implementations§
impl Freeze for Websocket
impl RefUnwindSafe for Websocket
impl Send for Websocket
impl Sync for Websocket
impl Unpin for Websocket
impl UnsafeUnpin for Websocket
impl UnwindSafe for Websocket
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