/// <summary>
        /// Closes the listener.
        /// </summary>
        private void InternalClose(object state)
        {
            TcpAsyncOperation <int> operation = (TcpAsyncOperation <int>)state;

            try
            {
                lock (m_lock)
                {
                    while (m_channelQueue.Count > 0)
                    {
                        UaTcpReplyChannel channel = m_channelQueue.Dequeue();
                        channel.Abort();
                    }

                    while (m_acceptQueue.Count > 0)
                    {
                        TcpAsyncOperation <IReplySessionChannel> waitingAccept = m_acceptQueue.Dequeue();
                        waitingAccept.Fault(StatusCodes.BadServerHalted);
                    }

                    Stop();
                }

                operation.Complete(0);
            }
            catch (Exception e)
            {
                operation.Fault(e, StatusCodes.BadInternalError, "Could not close UA TCP listener.");
            }
        }
Example #2
0
        /// <summary>
        /// Cancels all outstanding requests.
        /// </summary>
        private void InternalClose(object state)
        {
            TcpAsyncOperation <int> operation = (TcpAsyncOperation <int>)state;

            try
            {
                lock (m_lock)
                {
                    while (m_requestQueue.Count > 0)
                    {
                        RequestContext context = m_requestQueue.Dequeue();;
                        // Utils.Trace("Request Aborted: ChannelId={0}, RequestId={1}", this.m_channel.Id, context.RequestId);
                        context.Abort();
                    }

                    while (m_operationQueue.Count > 0)
                    {
                        TcpAsyncOperation <RequestContext> receiveOperation = m_operationQueue.Dequeue();
                        receiveOperation.Complete(null);
                    }
                }

                operation.Complete(0);
            }
            catch (Exception e)
            {
                operation.Fault(e, StatusCodes.BadInternalError, "Could not close a UA TCP reply channel.");
            }
        }
Example #3
0
        /// <summary>
        /// Closes the channel.
        /// </summary>
        private void InternalClose(object state)
        {
            TcpAsyncOperation <int> operation = (TcpAsyncOperation <int>)state;

            try
            {
                InternalClose(Int32.MaxValue);
                operation.Complete(0);
            }
            catch (Exception e)
            {
                operation.Fault(e, StatusCodes.BadInternalError, "Could not close UA TCP request channel.");
            }
        }
        /// <summary>
        /// Opens the listener.
        /// </summary>
        private void InternalOpen(object state)
        {
            TcpAsyncOperation <int> operation = (TcpAsyncOperation <int>)state;

            try
            {
                lock (m_lock)
                {
                    Start();
                }

                operation.Complete(0);
            }
            catch (Exception e)
            {
                operation.Fault(e, StatusCodes.BadInternalError, "Could not start UA TCP listener.");
            }
        }