private static void ReceiveMessageBase(ReceiveMessageState data) { var buffer = new byte[4]; data.Buffer = buffer; NetworkIo.Receive(data.Socket, data.Buffer, 0, 4, data, EndReceiveLengthCallback); }
private static void HandshakeMessageBase(ReceiveMessageState data) { var buffer = new byte[HandshakeMessage.Length]; data.Buffer = buffer; NetworkIo.Receive(data.Socket, data.Buffer, 0, buffer.Length, data, EndReceiveHandshakeCallback); }
private void RequireContextCallback(NativeActivityTransactionContext transactionContext, object state) { ReceiveMessageState state2 = state as ReceiveMessageState; transactionContext.SetRuntimeTransaction(state2.CurrentTransaction); NativeActivityContext executionContext = transactionContext; this.ServerScheduleOnReceivedMessage(executionContext, state2.Instance); }
/// <summary> /// 任务对象 /// </summary> /// <param name="id">任务ID</param> /// <param name="taskInfo">传输对象</param> /// <param name="state">状态</param> /// <param name="expirationTime">超时时间</param> /// <param name="socket">连接对象</param> public RemoteCallEntrity(Guid id, RequestExecutiveInformation taskInfo, ReceiveMessageState state, DateTime expirationTime, FRPCEasyClient socket) { this.ID = id; this.TaskInfo = taskInfo; this.State = state; this.ExpirationTime = expirationTime; this.ClientSocket = socket; WaitHandle = new AutoResetEvent(false); }
private void SetupTransaction(NativeActivityContext executionContext, ReceiveMessageInstanceData instance) { WorkflowOperationContext workflowOperationContext = instance.CorrelationResponseContext.WorkflowOperationContext; if (workflowOperationContext.CurrentTransaction != null) { RuntimeTransactionHandle handle = null; handle = executionContext.Properties.Find(runtimeTransactionHandlePropertyName) as RuntimeTransactionHandle; if (handle == null) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.ReceiveNotWithinATransactedReceiveScope)); } TransactedReceiveData data = executionContext.Properties.Find(TransactedReceiveData.TransactedReceiveDataExecutionPropertyName) as TransactedReceiveData; if ((data != null) && this.AdditionalData.IsFirstReceiveOfTransactedReceiveScopeTree) { data.InitiatingTransaction = workflowOperationContext.OperationContext.TransactionFacet.Current; } Transaction currentTransaction = handle.GetCurrentTransaction(executionContext); if (currentTransaction != null) { if (!currentTransaction.Equals(workflowOperationContext.CurrentTransaction)) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.FlowedTransactionDifferentFromAmbient)); } this.ServerScheduleOnReceivedMessage(executionContext, instance); } else { ReceiveMessageState state = new ReceiveMessageState { CurrentTransaction = workflowOperationContext.CurrentTransaction.Clone(), Instance = instance }; handle.RequireTransactionContext(executionContext, new Action <NativeActivityTransactionContext, object>(this.RequireContextCallback), state); } } else { this.ServerScheduleOnReceivedMessage(executionContext, instance); } }
public static void ReceiveHandshake(Socket socket, object state, MessageReceivedCallback callback) { ReceiveMessageState data = ReceiveCache.Get().Init(socket, state, callback); HandshakeMessageBase(data); }
private static void ReceiveMessageBase(ReceiveMessageState data) { var buffer = new byte[4]; data.Buffer = buffer; NetworkIO.Receive(data.Socket, data.Buffer, 0, 4, data, EndReceiveLengthCallback); }
private static void HandshakeMessageBase(ReceiveMessageState data) { var buffer = new byte[HandshakeMessage.Length]; data.Buffer = buffer; NetworkIO.Receive(data.Socket, data.Buffer, 0, buffer.Length, data, EndReceiveHandshakeCallback); }
// Phase 3: Setup Transaction for server receive case. // void SetupTransaction(NativeActivityContext executionContext, ReceiveMessageInstanceData instance) { WorkflowOperationContext workflowContext = instance.CorrelationResponseContext.WorkflowOperationContext; if (workflowContext.CurrentTransaction != null) { //get the RuntimeTransactionHandle from the ambient RuntimeTransactionHandle handle = null; handle = executionContext.Properties.Find(runtimeTransactionHandlePropertyName) as RuntimeTransactionHandle; if (handle != null) { //You are probably inside a TransactedReceiveScope //TransactedReceiveData is used to pass information about the Initiating Transaction to the TransactedReceiveScope //so that it can subsequently call Complete or Commit on it at the end of the scope TransactedReceiveData transactedReceiveData = executionContext.Properties.Find(TransactedReceiveData.TransactedReceiveDataExecutionPropertyName) as TransactedReceiveData; if (transactedReceiveData != null) { if (this.AdditionalData.IsFirstReceiveOfTransactedReceiveScopeTree) { Fx.Assert(workflowContext.OperationContext != null, "InternalReceiveMessage.SetupTransaction - Operation Context was null"); Fx.Assert(workflowContext.OperationContext.TransactionFacet != null, "InternalReceiveMessage.SetupTransaction - Transaction Facet was null"); transactedReceiveData.InitiatingTransaction = workflowContext.OperationContext.TransactionFacet.Current; } } Transaction currentTransaction = handle.GetCurrentTransaction(executionContext); if (currentTransaction != null) { if (!currentTransaction.Equals(workflowContext.CurrentTransaction)) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.FlowedTransactionDifferentFromAmbient)); } else { ServerScheduleOnReceivedMessage(executionContext, instance); return; } } ReceiveMessageState receiveMessageState = new ReceiveMessageState { CurrentTransaction = workflowContext.CurrentTransaction.Clone(), Instance = instance }; handle.RequireTransactionContext(executionContext, RequireContextCallback, receiveMessageState); return; } else { //Receive was probably not used within a TransactionFlowScope since no ambient transaction handle was found throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.ReceiveNotWithinATransactedReceiveScope)); } } ServerScheduleOnReceivedMessage(executionContext, instance); }
/// <summary> /// 修改结果并执行委托函数 /// </summary> /// <param name="state">状态</param> /// <param name="rpcResult">结果</param> public void ProcessingFuncInvoke(ReceiveMessageState state, string rpcResult) { State = state; ReturnValue = rpcResult; WaitHandle.Set(); }
/// <summary> /// 修改结果 /// </summary> /// <param name="state">状态</param> /// <param name="rpcResult">结果</param> public void ProcessingFuncInvoke(ReceiveMessageState state, string rpcResult) { TaskInfo.ReturnValue = rpcResult; State = state; ReturnValue = rpcResult; }
/// <summary> /// 任务存储 /// </summary> /// <param name="id">任务ID</param> /// <param name="taskInfo">任务信息</param> /// <param name="state">状态</param> /// <param name="expirationTime">过期时间</param> /// <param name="requestClient">请求对象</param> /// <param name="giveClient">转发对象</param> public ForwardingRequestEntity(Guid id, RequestExecutiveInformation taskInfo, ReceiveMessageState state, DateTime expirationTime, RRPCSession requestClient, RRPCSession giveClient) { this.ID = id; this.TaskInfo = taskInfo; this.State = state; this.ExpirationTime = expirationTime; this.RequestClient = requestClient; this.GiveClient = giveClient; }