本文整理汇总了C#中IRequestCallback类的典型用法代码示例。如果您正苦于以下问题:C# IRequestCallback类的具体用法?C# IRequestCallback怎么用?C# IRequestCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRequestCallback类属于命名空间,在下文中一共展示了IRequestCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: using
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
return CefReturnValue.Continue;
}
开发者ID:bjarteskogoy,项目名称:CefSharp,代码行数:35,代码来源:RequestHandler.cs
示例2: Uri
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame,
IRequest request, IRequestCallback callback) {
if (CommonUrls.IsWithSixUrl(request.Url)) {
var headers = request.Headers;
headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString();
headers[Common.ClientHeaderV] = Common.App.ProductVersion;
request.Headers = headers;
}
return CefReturnValue.Continue;
//Example of how to set Referer
// Same should work when setting any header
// For this example only set Referer when using our custom scheme
var url = new Uri(request.Url);
if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName
{
var headers = request.Headers;
headers["Referer"] = "http://google.com";
request.Headers = headers;
}
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed) {
using (callback) {
if (request.Method == "POST") {
using (var postData = request.PostData) {
if (postData != null) {
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements) {
if (element.Type == PostDataElementType.Bytes) {
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:60,代码来源:SixWebControlBehavior.cs
示例3: using
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
//To allow certificate
//callback.Continue(true);
//return true;
}
}
return false;
}
开发者ID:rasmusgude,项目名称:CefSharp,代码行数:15,代码来源:RequestHandler.cs
示例4:
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
try
{
//To allow certificate
//callback.Continue(true);
//return true;
return false;
}
finally
{
callback.Dispose();
}
}
开发者ID:bjarteskogoy,项目名称:CefSharp,代码行数:15,代码来源:RequestHandler.cs
示例5: using
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode,
string requestUrl, ISslInfo sslInfo, IRequestCallback callback) {
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed) {
using (callback) {
//To allow certificate
//callback.Continue(true);
//return true;
}
}
return false;
}
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:16,代码来源:SixWebControlBehavior.cs
示例6: using
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
if(postData != null)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
开发者ID:haozhouxu,项目名称:CefSharp,代码行数:47,代码来源:RequestHandler.cs
示例7: DeleteAllCookiesVisitor
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
// For some reason, in order to set cookies manually using a hdeader you need to clear the real cookies every time :/
Cef.GetGlobalCookieManager().VisitAllCookies(new DeleteAllCookiesVisitor());
if (request.Url.StartsWith("steammobile://"))
{
// Cancel all steammobile:// requests (for the app)
return CefReturnValue.Cancel;
}
else
{
var headers = request.Headers;
headers.Add("Cookie", Cookies);
headers.Add("X-Requested-With", "com.valvesoftware.android.steam.community");
request.Headers = headers;
return CefReturnValue.Continue;
}
}
开发者ID:808dkaneohe,项目名称:SteamDesktopAuthenticator,代码行数:19,代码来源:BrowserRequestHandler.cs
示例8:
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
try
{
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
finally
{
callback.Dispose();
}
return CefReturnValue.Continue;
}
开发者ID:klkn,项目名称:CefSharp,代码行数:21,代码来源:RequestHandler.cs
示例9: make_call
public new void make_call( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb )
{
Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'");
onServerResponse(responses[apicall] as String, apicall, cb);
}
开发者ID:yorrickm,项目名称:sdk-unity,代码行数:5,代码来源:MockRequestSender.cs
示例10: OnQuotaRequest
public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
{
return false;
}
开发者ID:chenguanzhou,项目名称:MarkDownEditor,代码行数:4,代码来源:RequestHandler.cs
示例11: OnCertificateError
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
return false;
}
开发者ID:chenguanzhou,项目名称:MarkDownEditor,代码行数:4,代码来源:RequestHandler.cs
示例12: OnBeforeResourceLoad
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
return CefReturnValue.Continue;
}
开发者ID:chenguanzhou,项目名称:MarkDownEditor,代码行数:4,代码来源:RequestHandler.cs
示例13: MakeCall
public new void MakeCall( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token )
{
Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'");
OnServerResponse(responses[apicall] as String, apicall, cb);
}
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:5,代码来源:MockRequestSender.cs
示例14: Uri
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
//Example of how to set Referer
// Same should work when setting any header
// For this example only set Referer when using our custom scheme
var url = new Uri(request.Url);
if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName)
{
//Referrer is now set using it's own method (was previously set in headers before)
request.SetReferrer("http://google.com", ReferrerPolicy.Default);
}
//Example of setting User-Agent in every request.
//var headers = request.Headers;
//var userAgent = headers["User-Agent"];
//headers["User-Agent"] = userAgent + " CefSharp";
//request.Headers = headers;
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
if(postData != null)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
开发者ID:Antonyo,项目名称:CefSharp,代码行数:66,代码来源:RequestHandler.cs
示例15: MakeCall
public void MakeCall( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb )
{
unityObject.DoCoroutine( SendCore( apicall, args, cb ) );
}
开发者ID:yorrickm,项目名称:sdk-unity,代码行数:4,代码来源:RequestSender.cs
示例16: TestOnServerResponse
public void TestOnServerResponse(string raw, string apicall, IRequestCallback cb)
{
OnServerResponse(raw, apicall, cb);
}
开发者ID:joaokucera,项目名称:sdk-unity,代码行数:4,代码来源:XmlError.cs
示例17: OnServerResponse
protected void OnServerResponse( string raw, string apicall, IRequestCallback cb )
{
var uc = apicall.Split("/"[0]);
var controller = uc[0];
var action = uc[1];
if (Debug.isDebugBuild)
Debug.Log(raw);
// Fire call complete event
RoarManager.OnRoarNetworkEnd("no id");
// -- Parse the Roar response
// Unexpected server response
if ( raw==null || raw.Length==0 || raw[0] != '<')
{
// Error: fire the error callback
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement error = doc.CreateElement("error");
doc.AppendChild(error);
error.AppendChild(doc.CreateTextNode(raw));
if (cb!=null)
{
cb.OnRequest(
new Roar.RequestResult(
RoarExtensions.CreateXmlElement("error",raw),
IWebAPI.FATAL_ERROR,
"Invalid server response"
) );
}
return;
}
System.Xml.XmlElement root = RoarExtensions.CreateXmlElement(raw);
int callback_code;
string callback_msg="";
System.Xml.XmlElement actionElement = root.SelectSingleNode( "/roar/"+controller+"/"+action ) as System.Xml.XmlElement;
// Pre-process <server> block if any and attach any processed data
System.Xml.XmlElement serverElement = root.SelectSingleNode( "/roar/server" ) as System.Xml.XmlElement;
RoarManager.NotifyOfServerChanges( serverElement );
// Status on Server returned an error. Action did not succeed.
string status = actionElement.GetAttribute( "status" );
if (status == "error")
{
callback_code = IWebAPI.UNKNOWN_ERR;
callback_msg = actionElement.SelectSingleNode("error").InnerText;
string server_error = (actionElement.SelectSingleNode("error") as System.Xml.XmlElement).GetAttribute("type");
if ( server_error == "0" )
{
if (callback_msg=="Must be logged in") { callback_code = IWebAPI.UNAUTHORIZED; }
if (callback_msg=="Invalid auth_token") { callback_code = IWebAPI.UNAUTHORIZED; }
if (callback_msg=="Must specify auth_token") { callback_code = IWebAPI.BAD_INPUTS; }
if (callback_msg=="Must specify name and hash") { callback_code = IWebAPI.BAD_INPUTS; }
if (callback_msg=="Invalid name or password") { callback_code = IWebAPI.DISALLOWED; }
if (callback_msg=="Player already exists") { callback_code = IWebAPI.DISALLOWED; }
logger.DebugLog(string.Format("[roar] -- response error: {0} (api call = {1})", callback_msg, apicall));
}
// Error: fire the callback
// NOTE: The Unity version ASSUMES callback = errorCallback
if (cb!=null) cb.OnRequest( new Roar.RequestResult(root, callback_code, callback_msg) );
}
// No error - pre-process the result
else
{
System.Xml.XmlElement auth_token = actionElement.SelectSingleNode(".//auth_token") as System.Xml.XmlElement;
if (auth_token!=null && !string.IsNullOrEmpty(auth_token.InnerText)) RoarAuthToken = auth_token.InnerText;
callback_code = IWebAPI.OK;
if (cb!=null) cb.OnRequest( new Roar.RequestResult( root, callback_code, callback_msg) );
}
RoarManager.OnCallComplete( new RoarManager.CallInfo( root, callback_code, callback_msg, "no id" ) );
}
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:80,代码来源:RequestSender.cs
示例18: MakeCall
public void MakeCall( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token )
{
unityObject.DoCoroutine( SendCore( apicall, args, cb, requires_auth_token ) );
}
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:4,代码来源:RequestSender.cs
示例19: SendCore
protected IEnumerator SendCore( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token )
{
if ( GameKey == "")
{
logger.DebugLog("[roar] -- No game key set!--");
yield break;
}
logger.DebugLog("[roar] -- Calling: "+apicall);
// Encode POST parameters
WWWForm post = new WWWForm();
if(args!=null)
{
foreach (DictionaryEntry param in args)
{
//Debug.Log(string.Format("{0} => {1}", param.Key, param.Value));
post.AddField( param.Key as string, param.Value as string );
}
}
if( requires_auth_token )
{
AddAuthToken(args,post);
}
// Fire call sending event
RoarManager.OnRoarNetworkStart();
//Debug.Log ( "roar_api_url = " + RoarAPIUrl );
if (Debug.isDebugBuild)
Debug.Log ( "Requesting : " + RoarAPIUrl+GameKey+"/"+apicall+"/" );
//NOTE: This is a work-around for unity not supporting zero length body for POST requests
if ( post.data.Length == 0 )
{
post.AddField("dummy","x");
}
var xhr = new WWW( RoarAPIUrl+GameKey+"/"+apicall+"/", post);
yield return xhr;
OnServerResponse( xhr.text, apicall, cb );
}
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:44,代码来源:RequestSender.cs
示例20: OnServerResponse
protected void OnServerResponse( string raw, string apicall, IRequestCallback<IXMLNode> cb )
{
var uc = apicall.Split("/"[0]);
var controller = uc[0];
var action = uc[1];
Debug.Log(raw);
// TEMP
/*
if (apicall == "shop/list")
{
raw = "<roar tick=\"135170282509\"><shop><list status=\"ok\"><shopitem ikey=\"rocket_fuel\" label=\"Rocket Fuel\" description=\"\"><costs><stat_cost type=\"currency\" ikey=\"gamecoins\" value=\"10\" ok=\"true\"/></costs><modifiers><grant_stat type=\"currency\" ikey=\"rocket_fuel\" value=\"100\"/></modifiers><tags/></shopitem><shopitem ikey=\"neil_armstrong\" label=\"Neil Armstrong\" description=\"Best copilot in the world\"><costs><stat_cost type=\"currency\" ikey=\"premium_currency\" value=\"15\" ok=\"false\" reason=\"Insufficient Premium Currency\"/></costs><modifiers><grant_item ikey=\"npc_armstrong\"/></modifiers><tags><tag value=\"copilot\"/></tags></shopitem><shopitem ikey=\"starter_space_pack\" label=\"Starter Space Pack\" description=\"Get going!\"><costs><stat_cost type=\"currency\" ikey=\"gamecoins\" value=\"20\" ok=\"true\"/></costs><modifiers><grant_stat type=\"currency\" ikey=\"rocket_fuel\" value=\"30\"/><grant_item ikey=\"regular_space_helmet\"/><grant_item ikey=\"rocket_ship\"/></modifiers><tags><tag value=\"pack\"/></tags></shopitem></list></shop></roar>";
}
*/
// Fire call complete event
RoarManager.OnRoarNetworkEnd("no id");
// -- Parse the Roar response
// Unexpected server response
if (raw[0] != '<')
{
// Error: fire the error callback
IXMLNode errorXml = IXMLNodeFactory.instance.Create("error", raw);
if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>(errorXml, IWebAPI.FATAL_ERROR, "Invalid server response" ) );
return;
}
IXMLNode rootNode = IXMLNodeFactory.instance.Create( raw );
int callback_code;
string callback_msg="";
IXMLNode actionNode = rootNode.GetNode( "roar>0>"+controller+">0>"+action+">0" );
// Hash XML keeping _name and _text values by default
// Pre-process <server> block if any and attach any processed data
IXMLNode serverNode = rootNode.GetNode( "roar>0>server>0" );
RoarManager.NotifyOfServerChanges( serverNode );
// Status on Server returned an error. Action did not succeed.
string status = actionNode.GetAttribute( "status" );
if (status == "error")
{
callback_code = IWebAPI.UNKNOWN_ERR;
callback_msg = actionNode.GetFirstChild("error").Text;
string server_error = actionNode.GetFirstChild("error").GetAttribute("type");
if ( server_error == "0" )
{
if (callback_msg=="Must be logged in") { callback_code = IWebAPI.UNAUTHORIZED; }
if (callback_msg=="Invalid auth_token") { callback_code = IWebAPI.UNAUTHORIZED; }
if (callback_msg=="Must specify auth_token") { callback_code = IWebAPI.BAD_INPUTS; }
if (callback_msg=="Must specify name and hash") { callback_code = IWebAPI.BAD_INPUTS; }
if (callback_msg=="Invalid name or password") { callback_code = IWebAPI.DISALLOWED; }
if (callback_msg=="Player already exists") { callback_code = IWebAPI.DISALLOWED; }
logger.DebugLog(string.Format("[roar] -- response error: {0} (api call = {1})", callback_msg, apicall));
}
// Error: fire the callback
// NOTE: The Unity version ASSUMES callback = errorCallback
if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>(rootNode, callback_code, callback_msg) );
}
// No error - pre-process the result
else
{
IXMLNode auth_token = actionNode.GetFirstChild("auth_token");
if (auth_token!=null) RoarAuthToken = auth_token.Text;
callback_code = IWebAPI.OK;
if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>( rootNode, callback_code, callback_msg) );
}
RoarManager.OnCallComplete( new RoarManager.CallInfo( rootNode, callback_code, callback_msg, "no id" ) );
}
开发者ID:yorrickm,项目名称:sdk-unity,代码行数:76,代码来源:RequestSender.cs
注:本文中的IRequestCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论