예제 #1
0
        public SenderMessageKey RemoveSenderMessageKey(uint iteration)
        {
            LinkedList <SenderKeyStateStructure.Types.SenderMessageKey>  keys     = new LinkedList <SenderKeyStateStructure.Types.SenderMessageKey>(senderKeyStateStructure.SenderMessageKeysList);
            IEnumerator <SenderKeyStateStructure.Types.SenderMessageKey> iterator = keys.GetEnumerator(); // iterator();

            SenderKeyStateStructure.Types.SenderMessageKey result = null;

            while (iterator.MoveNext())                                                             // hastNext
            {
                SenderKeyStateStructure.Types.SenderMessageKey senderMessageKey = iterator.Current; // next();

                if (senderMessageKey.Iteration == iteration)                                        //senderMessageKey.getIteration()
                {
                    result = senderMessageKey;
                    keys.Remove(senderMessageKey); //iterator.remove();
                    break;
                }
            }

            this.senderKeyStateStructure = this.senderKeyStateStructure.ToBuilder()
                                           .ClearSenderMessageKeys()
                                           //.AddAllSenderMessageKeys(keys)
                                           .AddRangeSenderMessageKeys(keys)
                                           .Build();

            if (result != null)
            {
                return(new SenderMessageKey(result.Iteration, result.Seed.ToByteArray()));
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public void addSenderMessageKey(SenderMessageKey senderMessageKey)
        {
            SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure =
                SenderKeyStateStructure.Types.SenderMessageKey.CreateBuilder()
                .SetIteration(senderMessageKey.getIteration())
                .SetSeed(ByteString.CopyFrom(senderMessageKey.getSeed()))
                .Build();

            this.senderKeyStateStructure = this.senderKeyStateStructure.ToBuilder()
                                           .AddSenderMessageKeys(senderMessageKeyStructure)
                                           .Build();
        }
        public void AddSenderMessageKey(SenderMessageKey senderMessageKey)
        {
            SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure = new SenderKeyStateStructure.Types.SenderMessageKey
            {
                Iteration = senderMessageKey.GetIteration(),
                Seed      = ByteString.CopyFrom(senderMessageKey.GetSeed())
            };
            _senderKeyStateStructure.SenderMessageKeys.Add(senderMessageKeyStructure);

            if (_senderKeyStateStructure.SenderMessageKeys.Count > MaxMessageKeys)
            {
                _senderKeyStateStructure.SenderMessageKeys.RemoveAt(0);
            }
        }
        public void addSenderMessageKey(SenderMessageKey senderMessageKey)
        {
            SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure = new SenderKeyStateStructure.Types.SenderMessageKey
            {
                Iteration = senderMessageKey.getIteration(),
                Seed      = ByteString.CopyFrom(senderMessageKey.getSeed())
            };
            this.senderKeyStateStructure.SenderMessageKeys.Add(senderMessageKeyStructure);

            if (senderKeyStateStructure.SenderMessageKeys.Count > MAX_MESSAGE_KEYS)
            {
                senderKeyStateStructure.SenderMessageKeys.RemoveAt(0);
            }
        }
예제 #5
0
        public void AddSenderMessageKey(SenderMessageKey senderMessageKey)
        {
            SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure =
                SenderKeyStateStructure.Types.SenderMessageKey.CreateBuilder()
                .SetIteration(senderMessageKey.GetIteration())
                .SetSeed(ByteString.CopyFrom(senderMessageKey.GetSeed()))
                .Build();

            SenderKeyStateStructure.Builder builder = this.senderKeyStateStructure.ToBuilder();
            builder.AddSenderMessageKeys(senderMessageKeyStructure);

            if (builder.SenderMessageKeysList.Count > MAX_MESSAGE_KEYS)
            {
                builder.SenderMessageKeysList.RemoveAt(0);
            }
            this.senderKeyStateStructure = builder.Build();
        }