protected override MessageBase CopyImpl(MessageBase clone) { // Instantiate the clone, if a derived type hasn't already. if (clone == null) clone = new RemotingMessage(); // Allow base type(s) to copy their state into the new clone. base.CopyImpl(clone); // Copy our state into the clone. ((RemotingMessage)clone)._source = _source; ((RemotingMessage)clone)._operation = _operation; return clone; }
protected override MessageBase CopyImpl(MessageBase clone) { // Instantiate the clone, if a derived type hasn't already. if (clone == null) { clone = new RemotingMessage(); } // Allow base type(s) to copy their state into the new clone. base.CopyImpl(clone); // Copy our state into the clone. ((RemotingMessage)clone)._source = _source; ((RemotingMessage)clone)._operation = _operation; return(clone); }
private IDictionary Invoke(IDictionary request) { ValidationUtils.ArgumentNotNull(request, "request"); object error = null; object result = null; ISession session = this.MessageBroker.SessionManager.GetHttpSession(HttpContext.Current); FluorineContext.Current.SetSession(session); //Context initialized, notify listeners. if (session != null && session.IsNew) session.NotifyCreated(); // Get the ID of the request. object id = request["id"]; string credentials = request["credentials"] as string; if (!StringUtils.IsNullOrEmpty(credentials)) { try { CommandMessage commandMessage = new CommandMessage(CommandMessage.LoginOperation); commandMessage.body = credentials; IMessage message = this.MessageBroker.RouteMessage(commandMessage); if (message is ErrorMessage) { error = FromException(message as ErrorMessage); return CreateResponse(id, result, error); } } catch (Exception ex) { error = FromException(ex); return CreateResponse(id, result, error); } } // If the ID is not there or was not set then this is a notification // request from the client that does not expect any response. Right // now, we don't support this. bool isNotification = JavaScriptConvert.IsNull(id); if (isNotification) throw new NotSupportedException("Notification are not yet supported."); log.Debug(string.Format("Received request with the ID {0}.", id.ToString())); // Get the method name and arguments. string methodName = StringUtils.MaskNullString((string)request["method"]); if (methodName.Length == 0) throw new JsonRpcException("No method name supplied for this request."); if (methodName == "clearCredentials") { try { CommandMessage commandMessage = new CommandMessage(CommandMessage.LogoutOperation); IMessage message = this.MessageBroker.RouteMessage(commandMessage); if (message is ErrorMessage) { error = FromException(message as ErrorMessage); return CreateResponse(id, result, error); } else return CreateResponse(id, message.body, null); } catch (Exception ex) { error = FromException(ex); return CreateResponse(id, result, error); } } //Info("Invoking method {1} on service {0}.", ServiceName, methodName); // Invoke the method on the service and handle errors. try { RemotingMessage message = new RemotingMessage(); message.destination = this.Request.QueryString["destination"] as string; message.source = this.Request.QueryString["source"] as string; message.operation = methodName; object argsObject = request["params"]; object[] args = (argsObject as JavaScriptArray).ToArray(); message.body = args; IMessage response = this.MessageBroker.RouteMessage(message); if (response is ErrorMessage) error = FromException(response as ErrorMessage); else result = response.body; /* Method method = serviceClass.GetMethodByName(methodName); object[] args; string[] names = null; object argsObject = request["params"]; IDictionary argByName = argsObject as IDictionary; if (argByName != null) { names = new string[argByName.Count]; argByName.Keys.CopyTo(names, 0); args = new object[argByName.Count]; argByName.Values.CopyTo(args, 0); } else { args = (argsObject as JavaScriptArray).ToArray(); } result = method.Invoke(instance, names, args); */ } catch (Exception ex) { log.Error(ex.Message, ex); throw; } // Setup and return the response object. return CreateResponse(id, result, error); }