Example #1
0
 /// <summary>
 /// Get all PDU's that were received since the last time
 /// this method was called.
 /// </summary>
 /// <returns>
 /// A collection of PDU's.
 /// </returns>
 public List <Pdu> GetEnqueuedPDUs()
 {
     lock (PduQueue)
     {
         List <Pdu> results = new List <Pdu>();
         while (PduQueue.Count != 0)
         {
             results.Add(PduQueue.Dequeue());
         }
         return(results);
     }
 }
Example #2
0
 /// <summary>
 /// Asynchrously processes bytes to pdu's and adds them to the queue.
 /// </summary>
 /// <param name="input">byte array to convert to one or multiple pdu's</param>
 protected virtual async void processPDUs(byte[] input)
 {
     await Task.Run(() =>
     {
         List <object> pduList = PduProcessor.ProcessPdu(input, Endian.Big);
         lock (PduQueue)
         {
             foreach (object pduObj in pduList)
             {
                 //check if the buffer has overflown
                 while (PduQueue.Count > BufferSize)
                 {
                     PduQueue.Dequeue();
                 }
                 PduQueue.Enqueue((Pdu)pduObj);
             }
         }
     });
 }