Ejemplo n.º 1
0
 private void OnMessageExecting(Events.EventMessageProcessArgs e)
 {
     if (MessageExecting != null)
     {
         MessageExecting(this, e);
     }
 }
Ejemplo n.º 2
0
        public void ProcessMessage(object message, ISession context)
        {
            Events.EventMessageProcessArgs mpa = new Events.EventMessageProcessArgs();
            mpa.Application = this.mApplication;
            mpa.Cancel      = false;
            mpa.Session     = context;
            mpa.Message     = message;
            OnMessageExecting(mpa);
            if (mpa.Cancel)
            {
                return;
            }
            IMethodHandler handler = null;

            if (mHandlers.TryGetValue(message.GetType(), out handler))
            {
                object data = new object[] { handler, context, message };
                if (handler.UseThreadPool)
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(OnProcessMessage, data);
                }
                else
                {
                    OnProcessMessage(data);
                }
            }
            else
            {
                "{0} messgae action notfound".Log4Error(message.GetType());
            }
        }
Ejemplo n.º 3
0
        public void ProcessMessage(object message, ISession context)
        {
            Events.EventMessageProcessArgs mpa = new Events.EventMessageProcessArgs();
            mpa.Application = this.mApplication;
            mpa.Cancel = false;
            mpa.Session = context;
            mpa.Message = message;
            OnMessageExecting(mpa);
            if (mpa.Cancel)
                return;
            IMethodHandler handler = null;
            RemoteInvokeArgs invokeArgs = (RemoteInvokeArgs)context[SOA_INVOKE_TAG];
            if (message is RPC.MethodCall)
            {
                invokeArgs = new RemoteInvokeArgs((RPC.MethodCall)message);
                context[SOA_INVOKE_TAG] = invokeArgs;
            }
            else
            {
                if (invokeArgs == null)
                {
                    if (mControllerHandlers.TryGetValue(message.GetType(), out handler))
                    {

                        object data = new object[] { handler, context, message };
                        if (handler.UseThreadPool)
                        {
                            System.Threading.ThreadPool.QueueUserWorkItem(OnControllerProcess, data);
                        }
                        else
                        {
                            OnControllerProcess(data);
                        }

                    }
                    else
                    {
                        "{0} messgae action notfound".Log4Error(message.GetType());
                    }
                    return;
                }
                else
                {
                    invokeArgs.AddParameter(message);
                }
            }
            if (invokeArgs.HasCompleted)
            {
                context[SOA_INVOKE_TAG] = null;
                string key = invokeArgs.GetKey();
                if (mSoaHandlers.TryGetValue(key, out handler))
                {

                    object data = new object[] { handler, context, invokeArgs.Parameters, invokeArgs };
                    if (handler.UseThreadPool)
                    {
                        System.Threading.ThreadPool.QueueUserWorkItem(OnSOAProcess, data);
                    }
                    else
                    {
                        OnSOAProcess(data);
                    }
                }
                else
                {
                    RPC.MethodResult result = new RPC.MethodResult();
                    result.Status = ResultStatus.Error;
                    result.Error = string.Format("{0} method not found!", key);
                    mApplication.Server.Send(result, context.Channel);
                    "{0} method notfound".Log4Error(key);
                }
            }


        }
Ejemplo n.º 4
0
        public void ProcessMessage(object message, ISession context)
        {
            Events.EventMessageProcessArgs mpa = new Events.EventMessageProcessArgs();
            mpa.Application = this.mApplication;
            mpa.Cancel = false;
            mpa.Session = context;
            mpa.Message = message;
            OnMessageExecting(mpa);
            if (mpa.Cancel)
                return;
            IMethodHandler handler = null;
            if (mHandlers.TryGetValue(message.GetType(), out handler))
            {
                
                object data = new object[] { handler,context,message};
                if (handler.UseThreadPool)
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(OnProcessMessage, data);
                }
                else
                {
                    OnProcessMessage(data);
                }
            }
            else
            {
                "{0} messgae action notfound".Log4Error(message.GetType());
            }

        }
Ejemplo n.º 5
0
        public void ProcessMessage(object message, ISession context)
        {
            Events.EventMessageProcessArgs mpa = new Events.EventMessageProcessArgs();
            mpa.Application = this.mApplication;
            mpa.Cancel      = false;
            mpa.Session     = context;
            mpa.Message     = message;
            OnMessageExecting(mpa);
            if (mpa.Cancel)
            {
                return;
            }
            IMethodHandler   handler    = null;
            RemoteInvokeArgs invokeArgs = (RemoteInvokeArgs)context[SOA_INVOKE_TAG];

            if (message is RPC.MethodCall)
            {
                invokeArgs = new RemoteInvokeArgs((RPC.MethodCall)message);
                context[SOA_INVOKE_TAG] = invokeArgs;
            }
            else
            {
                if (invokeArgs == null)
                {
                    if (mControllerHandlers.TryGetValue(message.GetType(), out handler))
                    {
                        object data = new object[] { handler, context, message };
                        if (handler.UseThreadPool)
                        {
                            System.Threading.ThreadPool.QueueUserWorkItem(OnControllerProcess, data);
                        }
                        else
                        {
                            OnControllerProcess(data);
                        }
                    }
                    else
                    {
                        "{0} messgae action notfound".Log4Error(message.GetType());
                    }
                    return;
                }
                else
                {
                    invokeArgs.AddParameter(message);
                }
            }
            if (invokeArgs.HasCompleted)
            {
                context[SOA_INVOKE_TAG] = null;
                string key = invokeArgs.GetKey();
                if (mSoaHandlers.TryGetValue(key, out handler))
                {
                    object data = new object[] { handler, context, invokeArgs.Parameters, invokeArgs };
                    if (handler.UseThreadPool)
                    {
                        System.Threading.ThreadPool.QueueUserWorkItem(OnSOAProcess, data);
                    }
                    else
                    {
                        OnSOAProcess(data);
                    }
                }
                else
                {
                    RPC.MethodResult result = new RPC.MethodResult();
                    result.Status = ResultStatus.Error;
                    result.Error  = string.Format("{0} method not found!", key);
                    mApplication.Server.Send(result, context.Channel);
                    "{0} method notfound".Log4Error(key);
                }
            }
        }