コード例 #1
0
        public ResponsePDU WaitResponse(RequestPDU pdu, int timeOut)
        {
            uint        sequenceNumber = pdu.Header.SequenceNumber;
            ResponsePDU resp           = FetchResponse(sequenceNumber);

            if (resp != null)
            {
                return(resp);
            }
            if (timeOut < 5000)
            {
                timeOut = vDefaultResponseTimeout;
            }
            PDUWaitContext waitContext = new PDUWaitContext(sequenceNumber, timeOut);

            vWaitingEvent.WaitOne();
            try { vWaitingQueue[sequenceNumber] = waitContext; }
            finally { vWaitingEvent.Set(); }
            waitContext.WaitForAlert();
            resp = FetchResponse(sequenceNumber);
            if (resp == null)
            {
                throw new SmppResponseTimedOutException();
            }
            return(resp);
        }
コード例 #2
0
 public void Handle(ResponsePDU pdu)
 {
     AddResponse(pdu);
     vWaitingEvent.WaitOne();
     try
     {
         uint sequenceNumber = pdu.Header.SequenceNumber;
         for (int index = 0; index < vWaitingQueue.Count; ++index)
         {
             PDUWaitContext waitContext = vWaitingQueue[index];
             if (waitContext.SequenceNumber == sequenceNumber)
             {
                 vWaitingQueue.RemoveAt(index);
                 waitContext.AlertResponseReceived();
                 if (waitContext.TimedOut)
                 {
                     FetchResponse(sequenceNumber);
                 }
                 return;
             }
         }
     }
     finally { vWaitingEvent.Set(); }
 }