override public Connection CreateConnection(Message request, Connection requestingCnn, Connection newCnn = null)
        {
            IPAddress  ip        = ((TCPListener)requestingCnn).IP;
            List <int> usedPorts = new List <int>();

            foreach (var ccnn in Connections.Values)
            {
                usedPorts.Add(((TCPListener)ccnn).Port);
            }
            usedPorts.Sort();
            int port = BasePort + 1;

            foreach (var p in usedPorts)
            {
                if (p > port)
                {
                    break;
                }
                else
                {
                    port++;
                }
            }

            String      id       = CreateNewConnectionID();
            TCPListener listener = new TCPListener(id, ip, port, -1, -1);

            return(base.CreateConnection(request, requestingCnn, listener));
        }
        override protected Message CreateRequestResponse(Message request, Connection newCnn, Connection oldCnn = null)
        {
            var         response = base.CreateRequestResponse(request, newCnn, oldCnn);
            TCPListener listener = newCnn != null ? (TCPListener)newCnn : (oldCnn != null ? (TCPListener)oldCnn: null);

            if (listener != null)
            {
                response.AddValue("Port", listener.Port);
                response.AddValue("IP", listener.IP.ToString());
            }
            response.DefaultEncoding = MessageEncoding.JSON;
            return(response);
        }
        override public Connection CreatePrimaryConnection(String connectionString, Connection newCcnn = null)
        {
            String    id = CreateNewConnectionID();
            IPAddress ip;

            if (connectionString == null)
            {
                ip = LocalIP;
            }
            else
            {
                ip = IPAddress.Parse(connectionString);
            }

            TCPListener listener = new TCPListener(id, ip, BasePort);

            return(base.CreatePrimaryConnection(connectionString, listener));
        }