예제 #1
0
        public SmppRemoteException(string message, SmppRequest request, SmppResponse response)
            : base(message)
        {
            if (request == null) throw new ArgumentNullException("request");
            if (response == null) throw new ArgumentNullException("response");

            Request = request;
            Response = response;
            CommandStatus = response.CommandStatus;
        }
예제 #2
0
        /// <summary>
        /// Sends a request and waits for the appropiate response.
        /// If no response is received before RequestTimeout seconds, an 
        /// SmppTimeoutException is thrown.
        /// </summary>
        /// <param name="request">The request.</param>
        public SmppResponse SendRequest(SmppRequest request)
        {
            RequestState state;

            lock (_RequestsAwaitingResponse)
            {
                state = new RequestState(SendPdu(request));
                _RequestsAwaitingResponse.Add(state.SequenceNumber, state);
            }

            var signalled = state.EventHandler.WaitOne(_ResponseTimeout);

            lock (_RequestsAwaitingResponse)
            {
                _RequestsAwaitingResponse.Remove(state.SequenceNumber);

                if (signalled)
                {
                    return state.Response;
                } else {
                    throw new SmppTimeoutException("Timeout while waiting for a response from remote side.");
                }
            }
        }