public void RemoveMessage(ShadowCompletionMessage message) { PeerMessageQueue peerQueue; if (!_savedMessages.TryGetValue(message.ToPeer, out peerQueue)) { peerQueue = new PeerMessageQueue(message.ToPeer); _savedMessages.Add(message.ToPeer, peerQueue); } if (peerQueue[message.Endpoint].Count == 0 || peerQueue.GlobalQueue.Count == 0) { peerQueue.OutOfOrderAcks.Add(message.MessageId, message); return; } var item = peerQueue.GlobalQueue.Peek(); if (item.Message.MessageIdentity != message.MessageId) { peerQueue.OutOfOrderAcks.Add(message.MessageId, message); } else { peerQueue.GlobalQueue.Dequeue(); RemoveFromTransportQueue(message.Endpoint, message.MessageId, peerQueue); } }
private void SendToSelfShadows(Guid messageId, bool processSuccessful, PeerId originatingPeer, IEndpoint originalEndpoint, string originalMessageType, OutboundDisruptorEntry data) { var selfShadows = _selfShadows ?? Enumerable.Empty<ServicePeer>(); if (selfShadows.Any()) { var message = new ShadowCompletionMessage(messageId, originatingPeer, _peerConfiguration.PeerId, processSuccessful, originalEndpoint, originalMessageType); var endpoints = selfShadows.Select(x => x.HandledMessages.Single(y => y.MessageType == typeof(ShadowCompletionMessage)).Endpoint).Distinct(); foreach (var shadowEndpoint in endpoints) { var messageData = CreateMessageWireData(message); var wireMessage = new WireSendingMessage(messageData, shadowEndpoint); data.NetworkSenderData.WireMessages.Add(wireMessage); } } }