本文整理汇总了C#中CefBrowser.SendProcessMessage方法的典型用法代码示例。如果您正苦于以下问题:C# CefBrowser.SendProcessMessage方法的具体用法?C# CefBrowser.SendProcessMessage怎么用?C# CefBrowser.SendProcessMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CefBrowser
的用法示例。
在下文中一共展示了CefBrowser.SendProcessMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendQuerySuccess
private void SendQuerySuccess(CefBrowser browser, int contextId, int requestId, string response)
{
var message = CefProcessMessage.Create(_queryMessageName);
var args = message.Arguments;
args.SetInt(0, contextId);
args.SetInt(1, requestId);
args.SetBool(2, true); // Indicates a success result.
args.SetString(3, response);
browser.SendProcessMessage(CefProcessId.Renderer, message);
args.Dispose();
message.Dispose();
}
示例2: SendQuery
// Returns the new request ID.
private int SendQuery(CefBrowser browser, long frameId, int contextId, string request, bool persistent, CefV8Value successCallback, CefV8Value failureCallback)
{
Helpers.RequireRendererThread();
var requestId = _requestIdGenerator.GetNextId();
var info = new RequestInfo
{
Persistent = persistent,
SuccessCallback = successCallback,
FailureCallback = failureCallback,
};
_browserRequestInfoMap.Add(browser.Identifier, new KeyValuePair<int, int>(contextId, requestId), info);
var message = CefProcessMessage.Create(_queryMessageName);
var args = message.Arguments;
args.SetInt(0, Helpers.Int64GetLow(frameId));
args.SetInt(1, Helpers.Int64GetHigh(frameId));
args.SetInt(2, contextId);
args.SetInt(3, requestId);
args.SetString(4, request);
args.SetBool(5, persistent);
browser.SendProcessMessage(CefProcessId.Browser, message);
args.Dispose();
message.Dispose();
return requestId;
}
示例3: SendQueryFailure
private void SendQueryFailure(CefBrowser browser, int contextId, int requestId, int errorCode, string errorMessage)
{
var message = CefProcessMessage.Create(_queryMessageName);
var args = message.Arguments;
args.SetInt(0, contextId);
args.SetInt(1, requestId);
args.SetBool(2, false); // Indicates a failure result.
args.SetInt(3, errorCode);
args.SetString(4, errorMessage);
browser.SendProcessMessage(CefProcessId.Renderer, message);
args.Dispose();
message.Dispose();
}
示例4: SendCancel
// If |requestId| is kReservedId all requests associated with |contextId|
// will be canceled, otherwise only the specified |requestId| will be
// canceled. Returns true if any request was canceled.
private bool SendCancel(CefBrowser browser, long frameId, int contextId, int requestId)
{
Helpers.RequireRendererThread();
var browserId = browser.Identifier;
int cancelCount = 0;
if (requestId != CefMessageRouter.ReservedId)
{
// Cancel a single request.
bool removed = false;
var info = GetRequestInfo(browserId, contextId, requestId, true, ref removed);
if (info != null)
{
Debug.Assert(removed);
info.Dispose();
cancelCount = 1;
}
}
else
{
// Cancel all requests with the specified context ID.
BrowserRequestInfoMap.Visitor visitor = (int vBrowserId, KeyValuePair<int, int> vInfoId, RequestInfo vInfo, ref bool vRemove) =>
{
if (vInfoId.Key == contextId)
{
vRemove = true;
vInfo.Dispose();
cancelCount++;
}
return true;
};
_browserRequestInfoMap.FindAll(browserId, visitor);
}
if (cancelCount > 0)
{
var message = CefProcessMessage.Create(_cancelMessageName);
var args = message.Arguments;
args.SetInt(0, contextId);
args.SetInt(1, requestId);
browser.SendProcessMessage(CefProcessId.Browser, message);
return true;
}
return false;
}