/**
         * Creates and starts a new access point according to the given descriptor.
         * If the specified access point has already been installed the method
         * has no effect.
         *
         * @param apDescriptor   a description of the access point to create.
         * @throws StunException if we fail to create or start the accesspoint.
         */
        public virtual void InstallNetAccessPoint(NetAccessPointDescriptor apDescriptor)
        {
            if (netAccessPoints.ContainsKey(apDescriptor))
            {
                return;
            }

            NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this);

            netAccessPoints[apDescriptor] = ap;

            ap.Start();
        }
        /**
         * Creates and starts a new access point based on the specified socket.
         * If the specified access point has already been installed the method
         * has no effect.
         *
         * @param  socket   the socket that the access point should use.
         * @return an access point descriptor to allow further management of the
         * newly created access point.
         * @throws StunException if we fail to create or start the accesspoint.
         */

        public NetAccessPointDescriptor InstallNetAccessPoint(MyUdpClient socket)
        {
            //no null check - let it through a null pointer exception
            StunAddress address = new StunAddress(socket.GetAddress().ToString(), socket.GetPort());
            NetAccessPointDescriptor apDescriptor = new NetAccessPointDescriptor(address);

            if (netAccessPoints.ContainsKey(apDescriptor))
            {
                return(apDescriptor);
            }

            NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this);

            //call the useExternalSocket method to avoid closing the socket when
            //removing the accesspoint. Bug Report - Dave Stuart - SipQuest
            ap.UseExternalSocket(socket);
            netAccessPoints[apDescriptor] = (ap);

            ap.Start();

            return(apDescriptor);
        }
        /**
         * Creates and starts a new access point based on the specified socket.
         * If the specified access point has already been installed the method
         * has no effect.
         *
         * @param  socket   the socket that the access point should use.
         * @return an access point descriptor to allow further management of the
         * newly created access point.
         * @throws StunException if we fail to create or start the accesspoint.
         */
        public NetAccessPointDescriptor InstallNetAccessPoint(MyUdpClient socket)
        {
            //no null check - let it through a null pointer exception
            StunAddress address = new StunAddress(socket.GetAddress().ToString(), socket.GetPort());
            NetAccessPointDescriptor apDescriptor = new NetAccessPointDescriptor(address);

            if(netAccessPoints.ContainsKey(apDescriptor))
                return apDescriptor;

            NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this);
            //call the useExternalSocket method to avoid closing the socket when
            //removing the accesspoint. Bug Report - Dave Stuart - SipQuest
            ap.UseExternalSocket(socket);
            netAccessPoints[apDescriptor] = (ap);

            ap.Start();

            return apDescriptor;
        }
        /**
         * Creates and starts a new access point according to the given descriptor.
         * If the specified access point has already been installed the method
         * has no effect.
         *
         * @param apDescriptor   a description of the access point to create.
         * @throws StunException if we fail to create or start the accesspoint.
         */
        public virtual void InstallNetAccessPoint(NetAccessPointDescriptor apDescriptor)
        {
            if(netAccessPoints.ContainsKey(apDescriptor))
                return;

            NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this);
            netAccessPoints[apDescriptor] = ap;

            ap.Start();
        }