Beispiel #1
0
        private void OnProcessMessage(object data)
        {
            object[]       array   = (object[])data;
            IMethodHandler handler = (IMethodHandler)array[0];
            ISession       context = (ISession)array[1];
            object         message = array[2];

            Session.Current = context;
            try
            {
                MethodContext mc = new MethodContext(mApplication, context, new object[] { context, message }, handler);

                mc.Execute();
                if (mc.Result != null)
                {
                    mApplication.Server.Send(mc.Result, context.Channel);
                }
            }
            catch (Exception e_)
            {
                "{0} invoke error ".Log4Error(e_, handler.ToString());
                context.Channel.InvokeError(e_);
            }
            finally
            {
                Session.Current = null;
            }
        }
Beispiel #2
0
        private void OnSOAProcess(object data)
        {
            object[]       array   = (object[])data;
            IMethodHandler handler = (IMethodHandler)array[0];
            ISession       context = (ISession)array[1];

            object[]         message = (object[])array[2];
            RemoteInvokeArgs riargs  = (RemoteInvokeArgs)array[3];

            RPC.MethodResult result = new RPC.MethodResult();
            result.ID = riargs.CallID;
            Implement.Session.Current = context;
            result.Status             = ResultStatus.Success;
            MethodContext   mc;
            object          rdata        = null;
            IList <Message> returnValues = new List <Message>();

            returnValues.Add(new Message(result, typeof(RPC.MethodResult)));
            IList <string> refParameters = null;

            try
            {
                mc = new MethodContext(mApplication, context, message, handler);
                mc.Execute();
                rdata         = mc.Result;
                result.IsVoid = handler.Info.ReturnType == typeof(void);
                if (!result.IsVoid)
                {
                    returnValues.Add(new Message(rdata, handler.Info.ReturnType));
                }
                if (handler.Parameters.Length > 0)
                {
                    result.Parameters = new string[handler.Parameters.Length];
                    for (int i = 0; i < handler.Parameters.Length; i++)
                    {
                        System.Reflection.ParameterInfo pi = handler.Parameters[i];
                        if (pi.IsOut || pi.IsRetval)
                        {
                            if (refParameters == null)
                            {
                                refParameters = new List <string>();
                            }
                            Type ptype = pi.ParameterType;
                            returnValues.Add(new Message(message[i], ptype.Name.IndexOf('&') == -1 ? ptype : ptype.GetElementType()));
                            refParameters.Add(pi.Name);
                        }
                    }
                    if (refParameters != null)
                    {
                        result.Parameters = refParameters.ToArray();
                    }
                }
            }
            catch (Exception e_)
            {
                result.Status = ResultStatus.Error;
                result.Error  = e_.Message;
                "{0} invoke error ".Log4Error(e_, handler.ToString());
                context.Channel.InvokeError(e_);
            }
            finally
            {
                Implement.Session.Current = null;
            }
            try
            {
                Beetle.Express.IData sdata = ((IPacketAnalyzer)context.Channel.Package).GetMessageData(returnValues);
                context.Application.Server.Send(sdata, context.Channel);
            }
            catch (Exception e__)
            {
                "{0} get return data error ".Log4Error(e__, handler.ToString());
                context.Channel.InvokeError(e__);
            }
        }