UCefView
Loading...
Searching...
No Matches
UCefViewQuery

Represents a query sent from the CEF (Chromium Embedded Framework) browser to the Unreal Engine. This class encapsulates the query ID, request content, and methods for replying to the query. More...

#include <CefViewQuery.h>

Public Member Functions

int64 GetId () const
 Gets the unique identifier for this query.
 
FString GetRequest () const
 Gets the content of the query as sent from the browser.
 
void Reply () const
 Replies to the query with the specified success status, response, and error code.
 

Public Attributes

bool IsSuccess = false
 Indicates whether the query was processed successfully.
 
int32 ErrorCode = 0
 Error code associated with the query, if any.
 
FString Response
 The response data for the query.
 

Protected Member Functions

void SetIdAndRequest (int64 InId, const FString &InRequest)
 Sets the query ID and request content.
 
void MarkAsReplied () const
 Marks the query as replied (for internal use only).
 

Detailed Description

Represents a query sent from the CEF (Chromium Embedded Framework) browser to the Unreal Engine. This class encapsulates the query ID, request content, and methods for replying to the query.

UCefViewQuery is used to handle asynchronous communication from JavaScript running in a CEF browser instance to the Unreal Engine application. Each query is uniquely identified and can be replied to with a result or error.

Queries are typically initiated from JavaScript using the CEF query API, and are received in Unreal as instances of this class. Use the provided methods and properties to inspect the query, process it, and send a response back to the browser.

Example usage in Blueprint:

Event OnCefViewQueryReceived(UCefViewQuery* Query)
{
if (Query->GetRequest() == "GetData")
{
Query->IsSuccess = true;
Query->Response = "SomeData";
}
else
{
Query->IsSuccess = false;
Query->ErrorCode = 404;
Query->Response = "Not found";
}
Query->Reply();
}
Represents a query sent from the CEF (Chromium Embedded Framework) browser to the Unreal Engine....
Definition CefViewQuery.h:58
int32 ErrorCode
Error code associated with the query, if any.
Definition CefViewQuery.h:92
FString Response
The response data for the query.
Definition CefViewQuery.h:108
FString GetRequest() const
Gets the content of the query as sent from the browser.
bool IsSuccess
Indicates whether the query was processed successfully.
Definition CefViewQuery.h:76
void Reply() const
Replies to the query with the specified success status, response, and error code.

Member Function Documentation

◆ GetId()

int64 UCefViewQuery::GetId ( ) const

Gets the unique identifier for this query.

Returns
The query id as a 64-bit integer.

The query ID is assigned by the CEF framework and is used to match responses to their corresponding requests.

◆ GetRequest()

FString UCefViewQuery::GetRequest ( ) const

Gets the content of the query as sent from the browser.

Returns
The request content string.

This string contains the data or command sent from JavaScript. It is typically a JSON-encoded string or a command name.

◆ MarkAsReplied()

void UCefViewQuery::MarkAsReplied ( ) const
protected

Marks the query as replied (for internal use only).

This method is used internally to prevent multiple replies to the same query.

◆ Reply()

void UCefViewQuery::Reply ( ) const

Replies to the query with the specified success status, response, and error code.

Call this method after setting IsSuccess, Response, and ErrorCode to send a response back to the browser. Once replied, the query cannot be replied to again.

This method is typically called from Blueprint or C++ after processing the query.

◆ SetIdAndRequest()

void UCefViewQuery::SetIdAndRequest ( int64 InId,
const FString & InRequest )
protected

Sets the query ID and request content.

Parameters
InIdThe query ID assigned by CEF.
InRequestThe request content string sent from the browser.

This method is intended for internal use to initialize the query object with data from the browser.

Member Data Documentation

◆ ErrorCode

int32 UCefViewQuery::ErrorCode = 0

Error code associated with the query, if any.

Set this property to a non-zero value to indicate an error. The meaning of the error code is application-specific. If IsSuccess is true, this value is typically ignored.

◆ IsSuccess

bool UCefViewQuery::IsSuccess = false

Indicates whether the query was processed successfully.

Set this property to true if the query was handled successfully, or false if an error occurred. This value is sent back to the browser as part of the query response.

◆ Response

FString UCefViewQuery::Response

The response data for the query.

Set this property to the string data you wish to return to the browser as the result of the query. This can be any serializable data, such as JSON or plain text.