本文整理汇总了C#中IClient.SendQueryInform方法的典型用法代码示例。如果您正苦于以下问题:C# IClient.SendQueryInform方法的具体用法?C# IClient.SendQueryInform怎么用?C# IClient.SendQueryInform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClient
的用法示例。
在下文中一共展示了IClient.SendQueryInform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnQuery
/// <summary>
/// Occurs when a remote client attempts to query a target within the application.
/// </summary>
/// <param name="client">The remote client.</param>
/// <param name="packet">The packet received.</param>
private static void OnQuery(IClient client, QueryRequest packet)
{
try
{
// Get method, arguments and the callback
var method = packet.Method;
var arguments = packet.Arguments;
var callback = packet.Callback;
var target = packet.Target;
// Do not query private methods
if (method.IsPrivateName())
return;
// Retrieves the target from the object lookup cache
var scope = ScriptMap.Get<PageScope>(target);
if (scope == null || scope.Channel == null)
return;
try
{
// Make sure we have a thread static session set
Channel.Current = scope.Channel;
Channel.Current.Caller = client;
// Get the session and add a client to it, this
// doesn't do anything if the client already exists
// on this session.
var session = scope.Channel.AddClient(client);
// TODO: Handle arguments
var result = scope.CallMethod(method, arguments, Channel.Current);
// Return in any case (whether we have a result or not)
client.SendQueryInform(callback, result);
}
catch (Exception ex)
{
// Send the exception
Channel.Current.SendException(ex);
}
finally
{
// Reset the scope back to null
Channel.Reset();
}
}
catch (Exception ex)
{
// Log the exception
Service.Logger.Log(ex);
}
}