/// <summary>
        /// Pushes a new message
        /// </summary>
        /// <param name="peer">Peer</param>
        /// <param name="message">Message</param>
        /// <param name="index">Starting index</param>
        /// <param name="length">Message length in bytes</param>
        public void PushMessage(ILocalPeer peer, byte[] message, uint index, uint length)
        {
            if (peer == null)
            {
                throw new ArgumentNullException(nameof(peer));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (index >= message.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "Starting index is out of range.");
            }
            if ((index + length) > message.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(length), "Starting index plus message length is bigger than message byte array.");
            }
            string key = peer.GUID.ToString();

            if (peerPeerLookup.ContainsKey(key))
            {
                localPeerReceiveMessages.Enqueue(new LocalPeerReceiveMessage(peerPeerLookup[key], message, index, length));
            }
        }
 /// <summary>
 /// Pushes a new message
 /// </summary>
 /// <param name="peer">Peer</param>
 /// <param name="message">Message</param>
 public void PushMessage(ILocalPeer peer, byte[] message)
 {
     if (message == null)
     {
         throw new ArgumentNullException(nameof(message));
     }
     PushMessage(peer, message, 0U, (uint)message.Length);
 }
        public void ReinitializeWithLocalPeer(ILocalPeer localPeer)
        {
            if (_initialized)
            {
                throw new InvalidOperationException();
            }
            DestroyWithLocalPeer();

            LocalPeer = localPeer;
            for (int i = 0; i < Configuration.SenderThreadsCount; i++)
            {
                _senderThreads.Add(new SubtSenderThread(this, "subtSenderThread" + i));
            }

            MeasurementsHistory.OnReinitialized(this);

            _initialized = true;
        }
 /// <summary>
 /// Constructs a local peer recieve message
 /// </summary>
 /// <param name="peer">Peer</param>
 /// <param name="message">Message</param>
 /// <param name="length">Starting index</param>
 /// <param name="length">Message length in bytes</param>
 public LocalPeerReceiveMessage(ILocalPeer peer, byte[] message, uint index, uint length)
 {
     if (message == null)
     {
         throw new ArgumentNullException(nameof(message));
     }
     if (index >= length)
     {
         throw new ArgumentException("Starting index is greater or equal to length.");
     }
     if ((index + length) > message.Length)
     {
         throw new ArgumentOutOfRangeException(nameof(length), "Starting index plus length is bigger than message length.");
     }
     Peer    = peer ?? throw new ArgumentNullException(nameof(peer));
     Message = message;
     Index   = index;
     Length  = length;
 }
Exemple #5
0
 /// <summary>
 /// Constructs a local peer disconnection message
 /// </summary>
 /// <param name="peer">Peer</param>
 public LocalPeerDisconnectionMessage(ILocalPeer peer) => Peer = peer ?? throw new ArgumentNullException(nameof(peer));