Exemplo n.º 1
0
        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)
            {
                MessageId       = msgId,
                ConnectionToken = conToken
            };

            return(res);
        }
Exemplo n.º 2
0
        public void ProcessReceivedAckBitfield(int bitField, MessageCounter msgId, short msgType)
        {
            var tmp = msgId;
            var bf  = (uint)bitField;

            while (bf != 0)
            {
                if ((bf & 1) == 1)
                {
                    // ReSharper disable once UseNullPropagation
                    if (MessageArrived != null)
                    {
                        MessageArrived.Invoke(tmp, msgType);
                    }
                }
                bf >>= 1;
                tmp--;
            }
        }