Skip to main content

_cef_server_handler_t

Struct _cef_server_handler_t 

Source
#[repr(C)]
pub struct _cef_server_handler_t { pub base: cef_base_ref_counted_t, pub on_server_created: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t)>, pub on_server_destroyed: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t)>, pub on_client_connected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>, pub on_client_disconnected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>, pub on_http_request: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, client_address: *const cef_string_t, request: *mut _cef_request_t)>, pub on_web_socket_request: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, client_address: *const cef_string_t, request: *mut _cef_request_t, callback: *mut _cef_callback_t)>, pub on_web_socket_connected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>, pub on_web_socket_message: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>, }
Expand description

Implement this structure to handle HTTP server requests. A new thread will be created for each cef_server_t::CreateServer call (the “dedicated server thread”), and the functions of this structure will be called on that thread. It is therefore recommended to use a different cef_server_handler_t instance for each cef_server_t::CreateServer call to avoid thread safety issues in the cef_server_handler_t implementation.

NOTE: This struct is allocated client-side.

Fields§

§base: cef_base_ref_counted_t

Base structure.

§on_server_created: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t)>

Called when |server| is created. If the server was started successfully then cef_server_t::IsRunning will return true (1). The server will continue running until cef_server_t::Shutdown is called, after which time OnServerDestroyed will be called. If the server failed to start then OnServerDestroyed will be called immediately after this function returns.

§on_server_destroyed: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t)>

Called when |server| is destroyed. The server thread will be stopped after this function returns. The client should release any references to |server| when this function is called. See OnServerCreated documentation for a description of server lifespan.

§on_client_connected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>

Called when a client connects to |server|. |connection_id| uniquely identifies the connection. Each call to this function will have a matching call to OnClientDisconnected.

§on_client_disconnected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>

Called when a client disconnects from |server|. |connection_id| uniquely identifies the connection. The client should release any data associated with |connection_id| when this function is called and |connection_id| should no longer be passed to cef_server_t functions. Disconnects can originate from either the client or the server. For example, the server will disconnect automatically after a cef_server_t::SendHttpXXXResponse function is called.

§on_http_request: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, client_address: *const cef_string_t, request: *mut _cef_request_t)>

Called when |server| receives an HTTP request. |connection_id| uniquely identifies the connection, |client_address| is the requesting IPv4 or IPv6 client address including port number, and |request| contains the request contents (URL, function, headers and optional POST data). Call cef_server_t functions either synchronously or asynchronusly to send a response.

§on_web_socket_request: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, client_address: *const cef_string_t, request: *mut _cef_request_t, callback: *mut _cef_callback_t)>

Called when |server| receives a WebSocket request. |connection_id| uniquely identifies the connection, |client_address| is the requesting IPv4 or IPv6 client address including port number, and |request| contains the request contents (URL, function, headers and optional POST data). Execute |callback| either synchronously or asynchronously to accept or decline the WebSocket connection. If the request is accepted then OnWebSocketConnected will be called after the WebSocket has connected and incoming messages will be delivered to the OnWebSocketMessage callback. If the request is declined then the client will be disconnected and OnClientDisconnected will be called. Call the cef_server_t::SendWebSocketMessage function after receiving the OnWebSocketConnected callback to respond with WebSocket messages.

§on_web_socket_connected: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int)>

Called after the client has accepted the WebSocket connection for |server| and |connection_id| via the OnWebSocketRequest callback. See OnWebSocketRequest documentation for intended usage.

§on_web_socket_message: Option<unsafe extern "C" fn(self_: *mut _cef_server_handler_t, server: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>

Called when |server| receives an WebSocket message. |connection_id| uniquely identifies the connection, |data| is the message content and |data_size| is the size of |data| in bytes. Do not keep a reference to |data| outside of this function. See OnWebSocketRequest documentation for intended usage.

Trait Implementations§

Source§

impl Clone for _cef_server_handler_t

Source§

fn clone(&self) -> _cef_server_handler_t

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for _cef_server_handler_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for _cef_server_handler_t

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.