private void AckArrivedHandler(MessageCounter arg1, short arg2) { lock (_messageBuffer) { var toRemove = _messageBuffer.FirstOrDefault(m => m.Msg.MessageId == arg1 && m.Msg.Header.Type == arg2); if (toRemove != null) { _messageBuffer.Remove(toRemove); } } }
internal static Message Ack(short type, MessageCounter msgId, Token conToken, int ackBitField) { var ds = DataStorage.CreateForWrite(); ds.Push(ackBitField); ds.Push(type); var res = new Message((short)MessageType.Ack, Mode.None, ds); res.MessageId = msgId; res.ConnectionToken = conToken; return(res); }
public void ProcessReceivedAckBitfield(int bitField, MessageCounter msgId, short msgType) { var tmp = msgId; uint bf = (uint)bitField; while (bf != 0) { if ((bf & 1) == 1) { if (MessageArrived != null) { MessageArrived.Invoke(tmp, msgType); } } bf >>= 1; tmp--; } }
internal MessageCounter GetMessageId(Message msg) { MessageCounter result = MessageCounter.Default; if (msg.Ordered) { lock (_lastOrderedMessageNumPerType) { if (!_lastOrderedMessageNumPerType.ContainsKey((short)msg.Header.Type)) { _lastOrderedMessageNumPerType.Add((short)msg.Header.Type, 0); } result = _lastOrderedMessageNumPerType[(short)msg.Header.Type]; _lastOrderedMessageNumPerType[(short)msg.Header.Type]++; } } else if (msg.Sequenced) { lock (_lastSequencedMessageNumPerType) { if (!_lastSequencedMessageNumPerType.ContainsKey((short)msg.Header.Type)) { _lastSequencedMessageNumPerType.Add((short)msg.Header.Type, 0); } result = _lastSequencedMessageNumPerType[(short)msg.Header.Type]; _lastSequencedMessageNumPerType[(short)msg.Header.Type]++; } } else { lock (_lastUnOrderedMessageNumPerType) { if (!_lastUnOrderedMessageNumPerType.ContainsKey((short)msg.Header.Type)) { _lastUnOrderedMessageNumPerType.Add((short)msg.Header.Type, 0); } result = _lastUnOrderedMessageNumPerType[(short)msg.Header.Type]; _lastUnOrderedMessageNumPerType[(short)msg.Header.Type]++; } } return(result); }
internal bool IsMessageInItsOrder(short type, MessageCounter num) { lock (_lastSequencedMessageNumPerType) { if (_lastSequencedMessageNumPerType.ContainsKey(type)) { if (_lastSequencedMessageNumPerType[type] < num) { _lastSequencedMessageNumPerType[type] = num; return(true); } else { return(false); } } else { _lastSequencedMessageNumPerType.Add(type, num); return(true); } } }