Exemplo n.º 1
0
 /// <summary>
 /// If the queue does not exist yet, returns the maximum number of packets in a queue.
 /// </summary>
 /// <param name="key">Unique queue identifier</param>
 /// <returns>Number of empty packet slots in the specified queue</returns>
 public ulong GetRemainingCapacity(ulong key)
 {
     lock (_locker)
     {
         return(_released ? 0 : UdpQueueInterop.GetRemainingCapacity(_instance, key));
     }
 }
Exemplo n.º 2
0
 public void Dispose()
 {
     lock (_locker)
     {
         _released = true;
         UdpQueueInterop.Destroy(_instance);
     }
 }
Exemplo n.º 3
0
        public bool QueuePacket(ulong key, string hostAddress, int port, byte[] data, ulong length)
        {
            lock (_locker)
            {
                if (_released)
                {
                    return(false);
                }

                Array.Copy(data, 0, _packetBuffer, 0, (int)length);

                return(UdpQueueInterop.QueuePacket(_instance, key, hostAddress, port, _packetBuffer, length));
            }
        }
Exemplo n.º 4
0
 public void Process()
 {
     // ReSharper disable once InconsistentlySynchronizedField
     UdpQueueInterop.Process(_instance);
 }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bufferCapacity">Maximum number of packets in one queue</param>
 /// <param name="packetInterval">Time interval between packets in a queue</param>
 /// <param name="maximumPacketSize">Maximum packet size</param>
 public UdpQueue(ulong bufferCapacity, long packetInterval, int maximumPacketSize)
 {
     _bufferCapacity = bufferCapacity;
     _packetBuffer   = new byte[maximumPacketSize];
     _instance       = UdpQueueInterop.Create(bufferCapacity, packetInterval);
 }