Exemplo n.º 1
0
        /// <summary>
        /// Creates a <see cref="SecureClientConnectionContainer"/> and connects it to the given IP address and port.
        /// </summary>
        /// <param name="ipAddress">The IP address to connect to.</param>
        /// <param name="port">The port to connect to.</param>
        /// <param name="rsaPair">The RSA key-pair to use.</param>
        /// <returns>The created <see cref="SecureClientConnectionContainer"/>.</returns>
        public static ClientConnectionContainer CreateSecureClientConnectionContainer(string ipAddress, int port, RSAPair rsaPair)
        {
            var secureClientConnectionContainer = new SecureClientConnectionContainer(ipAddress, port, rsaPair);

            secureClientConnectionContainer.Initialize();
            return(secureClientConnectionContainer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a <see cref="SecureClientConnectionContainer"/> with the given <see cref="TcpConnection"/> and <see cref="UdpConnection"/>.
        /// </summary>
        /// <param name="tcpConnection">The <see cref="TcpConnection"/> to use.</param>
        /// <param name="udpConnection">The <see cref="UdpConnection"/> to use.</param>
        /// <param name="rsaPair">The RSA key-pair to use.</param>
        /// <returns>The created <see cref="SecureClientConnectionContainer"/>.</returns>
        /// <exception cref="ArgumentException">Thrown if the given <see cref="TcpConnection"/> is not connected.</exception>
        public static ClientConnectionContainer CreateSecureClientConnectionContainer(TcpConnection tcpConnection, UdpConnection udpConnection, RSAPair rsaPair)
        {
            if (tcpConnection == null || !tcpConnection.IsAlive)
            {
                throw new ArgumentException("TCP connection must be connected to an endpoint.");
            }

            var secureClientConnectionContainer = new SecureClientConnectionContainer(tcpConnection, udpConnection, rsaPair);

            secureClientConnectionContainer.Initialize();
            return(secureClientConnectionContainer);
        }