cef_server_t

Structure representing a server that supports HTTP and WebSocket requests. Server capacity is limited and is intended to handle only a small number of simultaneous connections (e.g. for communicating between applications on localhost). The functions of this structure are safe to call from any thread in the brower process unless otherwise indicated.

version(cef && embedded_cef_bindings)
extern (C)
struct cef_server_t {
extern (System)
cef_task_runner_t* function(cef_server_t* self) nothrow get_task_runner;
}

Members

Variables

base
cef_base_ref_counted_t base;

Base structure.

close_connection
void function(cef_server_t* self, int connection_id) nothrow close_connection;

Close the connection identified by |connection_id|. See SendHttpResponse documentation for intended usage.

get_address
cef_string_userfree_t function(cef_server_t* self) nothrow get_address;

Returns the server address including the port number.

has_connection
int function(cef_server_t* self) nothrow has_connection;

Returns true (1) if the server currently has a connection. This function must be called on the dedicated server thread.

is_running
int function(cef_server_t* self) nothrow is_running;

Returns true (1) if the server is currently running and accepting incoming connections. See cef_server_handler_t::OnServerCreated documentation for a description of server lifespan. This function must be called on the dedicated server thread.

is_valid_connection
int function(cef_server_t* self, int connection_id) nothrow is_valid_connection;

Returns true (1) if |connection_id| represents a valid connection. This function must be called on the dedicated server thread.

send_http200response
void function(cef_server_t* self, int connection_id, const(cef_string_t)* content_type, const(void)* data, size_t data_size) nothrow send_http200response;

Send an HTTP 200 "OK" response to the connection identified by |connection_id|. |content_type| is the response content type (e.g. "text/html"), |data| is the response content, and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. The connection will be closed automatically after the response is sent.

send_http404response
void function(cef_server_t* self, int connection_id) nothrow send_http404response;

Send an HTTP 404 "Not Found" response to the connection identified by |connection_id|. The connection will be closed automatically after the response is sent.

send_http500response
void function(cef_server_t* self, int connection_id, const(cef_string_t)* error_message) nothrow send_http500response;

Send an HTTP 500 "Internal Server Error" response to the connection identified by |connection_id|. |error_message| is the associated error message. The connection will be closed automatically after the response is sent.

send_http_response
void function(cef_server_t* self, int connection_id, int response_code, const(cef_string_t)* content_type, long content_length, cef_string_multimap_t extra_headers) nothrow send_http_response;

Send a custom HTTP response to the connection identified by |connection_id|. |response_code| is the HTTP response code sent in the status line (e.g. 200), |content_type| is the response content type sent as the "Content-Type" header (e.g. "text/html"), |content_length| is the expected content length, and |extra_headers| is the map of extra response headers. If |content_length| is >= 0 then the "Content-Length" header will be sent. If |content_length| is 0 then no content is expected and the connection will be closed automatically after the response is sent. If |content_length| is < 0 then no "Content-Length" header will be sent and the client will continue reading until the connection is closed. Use the SendRawData function to send the content, if applicable, and call CloseConnection after all content has been sent.

send_raw_data
void function(cef_server_t* self, int connection_id, const(void)* data, size_t data_size) nothrow send_raw_data;

Send raw data directly to the connection identified by |connection_id|. |data| is the raw data and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. No validation of |data| is performed internally so the client should be careful to send the amount indicated by the "Content-Length" header, if specified. See SendHttpResponse documentation for intended usage.

send_web_socket_message
void function(cef_server_t* self, int connection_id, const(void)* data, size_t data_size) nothrow send_web_socket_message;

Send a WebSocket message to the connection identified by |connection_id|. |data| is the response content and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. See

shutdown
void function(cef_server_t* self) nothrow shutdown;

server lifespan.

Meta