Exemple #1
0
        protected void OnMessageReceived(IncomingMessage message)
        {
            message.IfPayloadIs <VersionPayload>(version =>
            {
                if (State == NodeState.HandShaked)
                {
                    if (message.Node.Version >= ProtocolVersion.REJECT_VERSION)
                    {
                        message.Node.SendMessageAsync(new RejectPayload()
                        {
                            Code = RejectCode.DUPLICATE
                        });
                    }
                }
            });
            //if(version != null)
            //{
            //	if((version.Services & NodeServices.NODE_WITNESS) != 0)
            //		_SupportedTransactionOptions |= TransactionOptions.Witness;
            //}
            //var havewitness = message.Message.Payload as HaveWitnessPayload;
            //if(havewitness != null)
            //	_SupportedTransactionOptions |= TransactionOptions.Witness;

            var last = new ActionFilter((m, n) =>
            {
                MessageProducer.PushMessage(m);
                var messageReceived = MessageReceived;

                if (messageReceived != null)
                {
                    foreach (var handler in messageReceived.GetInvocationList().Cast <NodeEventMessageIncoming>())
                    {
                        try
                        {
                            handler.DynamicInvoke(this, m);
                        }
                        catch (TargetInvocationException ex)
                        {
                            TraceCorrelation.LogInside(() => NodeServerTrace.Error("Error while OnMessageReceived event raised", ex.InnerException), false);
                        }
                    }
                }
            });

            var enumerator = Filters.Concat(new[] { last }).GetEnumerator();

            FireFilters(enumerator, message);
        }
Exemple #2
0
 public void PushMessage(IncomingMessage message)
 {
     _Prod.PushMessage(message);
 }