Exemple #1
0
        public void HandleAckMessage(AckMessage ackMessage)
        {
            OutboundMessage outboundMessage = null;

            if (outboundMessagesBySequence.TryGetValue(ackMessage.AckedSequenceNumber, out outboundMessage))
            {
                outboundMessages.Remove(outboundMessage);
                outboundMessagesBySequence.Remove(ackMessage.AckedSequenceNumber);
                outboundMessagePool.Push(outboundMessage);
            }
            if (isResetPending && outboundMessages.FirstOrDefault(x => x.NeedsAck) == null)
            {
                if (IsVerbose)
                {
                    NeutrinoConfig.Log(node.Name + " drained all outbound - resetting sequence and sending queued");
                }
                isResetPending = false;
                nextSequence   = 0;
                foreach (byte[] buffer in pendingResetOutboundMessages)
                {
                    Enqueue(msgFactory.Read(buffer));
                }
                pendingResetOutboundMessages.Clear();
            }
        }
Exemple #2
0
 private void Assign(NetworkMessage msg, OutboundMessage target)
 {
     target.ContainedMessageType = msg.GetType();
     if (msg.IsGuaranteed)
     {
         target.SequenceNumber = nextSequence++;
         outboundMessagesBySequence[target.SequenceNumber] = target;
         msg.SequenceNumber = target.SequenceNumber;
     }
     target.PayloadLength     = msg.Write(target.Payload);
     target.NeedsAck          = msg.IsGuaranteed;
     target.PreviousSendTicks = Environment.TickCount - resendGuaranteedPeriodTicks - 1;
     if (!(msg is ResetNetworkIdsMessage) && nextSequence == maxGuaranteedBeforeReset)
     {
         if (IsVerbose)
         {
             NeutrinoConfig.Log(node.Name + " reached max sequence - resetting...");
         }
         Enqueue(msgFactory.Get <ResetNetworkIdsMessage>());
         isResetPending = true;
     }
 }
 private void Assign(NetworkMessage msg, OutboundMessage target)
 {
     target.ContainedMessageType = msg.GetType();
     if (msg.IsGuaranteed)
     {
         target.SequenceNumber = nextSequence++;
         outboundMessagesBySequence[target.SequenceNumber] = target;
         msg.SequenceNumber = target.SequenceNumber;
     }
     target.PayloadLength = msg.Write(target.Payload);
     target.NeedsAck = msg.IsGuaranteed;
     target.PreviousSendTicks = Environment.TickCount - resendGuaranteedPeriodTicks - 1;
     if (!(msg is ResetNetworkIdsMessage) && nextSequence == maxGuaranteedBeforeReset)
     {
         if (IsVerbose)
             NeutrinoConfig.Log (node.Name + " reached max sequence - resetting...");
         Enqueue(msgFactory.Get<ResetNetworkIdsMessage>());
         isResetPending = true;
     }
 }