private void OnRMI(Message message, Protocols.RMIMessage rmimsg) { if (!string.IsNullOrEmpty(rmimsg.DeserializeError)) { message.Reply(new Protocols.Error() { Message = rmimsg.DeserializeError }); } else { RInterfaceInfo interfaceinfo = null; RMethodInfo methodinfo = null; RInterfaceFactory.Default.TryGet(rmimsg.Name, out interfaceinfo); interfaceinfo.TryGet(rmimsg.Method, out methodinfo); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke", rmimsg.Name, rmimsg.Method); RMethodResult result = methodinfo.Invoke(rmimsg.Parameters); if (result.Exception != null) { Protocols.Error error = new Protocols.Error() { Message = result.Exception.Message, StackTrace = result.Exception.StackTrace }; message.Reply(error); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke error {2}", rmimsg.Name, rmimsg.Method, result.Exception.Message); } else { if (result.IsVoid || result.Value == null) message.Reply(new Protocols.Success()); else message.Reply(result.Value); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke completed!", rmimsg.Name, rmimsg.Method); } } }
public Object MethodInvoke(string name, string method, params object[] parameters) { Protocols.RMIMessage msg = new Protocols.RMIMessage(); msg.Name = name; msg.Method = method; msg.Parameters = parameters; object result = PublishToService(name, msg); if (result is Protocols.Error) { throw new SRException(string.Format("Invoke {0}.{1} error {2}!", name, method, ((Protocols.Error)result).Message)); } if (result is Protocols.Success) return null; return result; }