Akka.Remote.Tests.Transport.AkkaProtocolStressTest.SequenceVerifier.OnReceive C# (CSharp) Method

OnReceive() protected method

protected OnReceive ( object message ) : void
message object
return void
            protected override void OnReceive(object message)
            {
                if (message.Equals("start"))
                {
                    Self.Tell("sendNext");
                }
                else if (message.Equals("sendNext") && NextSeq < Limit)
                {
                    _remote.Tell(NextSeq);
                    NextSeq++;
                    if (NextSeq%2000 == 0)
                        Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromMilliseconds(500), Self, "sendNext", Self);
                    else
                        Self.Tell("sendNext");
                }
                else if (message is int || message is long)
                {
                    var seq = Convert.ToInt32(message);
                    if (seq > MaxSeq)
                    {
                        Losses += seq - MaxSeq - 1;
                        MaxSeq = seq;

                        // Due to the (bursty) lossyness of gate, we are happy with receiving at least one message from the upper
                        // half (> 50000). Since messages are sent in bursts of 2000 0.5 seconds apart, this is reasonable.
                        // The purpose of this test is not reliable delivery (there is a gremlin with 30% loss anyway) but respecting
                        // the proper ordering.

                        if (seq > Limit*0.5)
                        {
                            _controller.Tell(Tuple.Create(MaxSeq, Losses));
                            Context.System.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), Self,
                                ResendFinal.Instance, Self);
                            Context.Become(Done);
                        }
                    }
                    else
                    {
                        _controller.Tell(string.Format("Received out of order message. Previous {0} Received: {1}", MaxSeq, seq));
                    }
                }
            }
AkkaProtocolStressTest.SequenceVerifier