示例#1
0
        private void ExecuteTransaction(IServerCallHandler handler)
        {
            try
            {
                var tx     = CurrentTransactionContext.Transaction;
                var retVal = handler.Execute(tx.Params.ToByteArray());
                if (retVal != null)
                {
                    CurrentTransactionContext.Trace.ReturnValue         = ByteString.CopyFrom(retVal);
                    CurrentTransactionContext.Trace.ReadableReturnValue = handler.ReturnBytesToString(retVal);
                }

                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.Executed;
            }
            catch (TargetInvocationException ex)
            {
                CurrentTransactionContext.Trace.Error          += ex;
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
            }
            catch (AssertionException ex)
            {
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += "\n" + ex;
            }
            catch (Exception ex)
            {
                // TODO: Simplify exception
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += "\n" + ex;
            }
        }
示例#2
0
        public ServerCallHandlerTests()
        {
            var method  = CreateMethod();
            var handler = CreateHandler();

            _callHandler = ServerCalls.UnaryCall(method, handler);
        }
示例#3
0
文件: Server.cs 项目: bazoocaze/CsFun
        private void OnProcessPacket(IPacketSession session, InternalPacket packet)
        {
            foreach (var service in m_Services)
            {
                IServerCallHandler methodHandler = null;
                if (service.CallHandlers.TryGetValue(packet.FullMethodName, out methodHandler))
                {
                    // TODO: Server: analise the need to store the call tasks.
                    methodHandler.HandleCall(session, packet);
                    return;
                }
            }

            // Discard unknow or unexpected packet
        }
示例#4
0
        private void ExecuteTransaction(IServerCallHandler handler)
        {
            try
            {
                var tx     = CurrentTransactionContext.Transaction;
                var retVal = handler.Execute(tx.Params.ToByteArray());
                if (retVal != null)
                {
                    CurrentTransactionContext.Trace.ReturnValue = ByteString.CopyFrom(retVal);
                }

                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.Executed;
            }
            catch (Exception ex)
            {
                CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
                CurrentTransactionContext.Trace.Error          += ex + "\n";
            }
        }