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; } }
public ServerCallHandlerTests() { var method = CreateMethod(); var handler = CreateHandler(); _callHandler = ServerCalls.UnaryCall(method, handler); }
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 }
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"; } }