Beispiel #1
0
    public void SendPong(PingMsg discoveryMsg)
    {
        PongMsg msg = new (ManagedNode.Address, CalculateExpirationTime(), discoveryMsg.Mdc !);

        _discoveryManager.SendMessage(msg);
        NodeStats.AddNodeStatsEvent(NodeStatsEventType.DiscoveryPongOut);
        // _sentPong = true;
        if (IsBonded)
        {
            UpdateState(NodeLifecycleState.Active);
        }
    }
Beispiel #2
0
    public void ProcessPingMsg(PingMsg pingMsg)
    {
        // _receivedPing = true;
        SendPong(pingMsg);
        if (pingMsg.EnrSequence is not null && pingMsg.EnrSequence > _lastEnrSequence)
        {
            SendEnrRequest();
        }

        NodeStats.AddNodeStatsEvent(NodeStatsEventType.DiscoveryPingIn);
        RefreshNodeContactTime();
    }
Beispiel #3
0
        public Task ReceiveAsync(IContext context)
        {
            switch (context.Message)
            {
            case Start s:
                _pong    = s.Sender;
                _replyTo = context.Sender;
                var m = new PingMsg(context.Self);

                _messageCount -= _batchSize;

                for (var i = 0; i < _batchSize; i++)
                {
                    context.Send(_pong, m);
                }

                break;

            case PongMsg:

                _messageCount--;

                if (_messageCount == 0)
                {
                    Console.Write(".");
                    context.Send(_replyTo, true);
                }
                else if (_messageCount > 0)
                {
                    context.Send(_pong, new PingMsg(context.Self));
                }

                break;
            }

            return(Task.CompletedTask);
        }