/// <summary> /// Invoked when an incoming request for Query operation comes in. /// </summary> public abstract void OnQuery(IClient client, QueryRequest packet);
/// <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); } }