コード例 #1
0
        /// <summary>
        /// Constructor for client initiated connections
        /// </summary>
        /// <param name="address">The address of the server to connect to</param>
        /// <param name="port">the port of the server to connect</param>
        public Connection(string address, int port, SslSettings sslSettings, Dictionary <string, string> data = null) : this(sslSettings)
        {
            // set random ID and connection direction
            ID       = Guid.NewGuid().ToString().Substring(0, 8);
            IsClient = true;

            _ipAddresses       = new List <IPAddress>();
            _port              = port;
            _sessionIdProvider = new IdProvider(0, 2);

            IPAddress ip;
            if (IPAddress.TryParse(address, out ip))
            {
                _ipAddresses.Add(ip);
            }
            else
            {
                _ipAddresses.AddRange(Utilities.GetHostAddressesAsync(address).ConfigureAwait(false).GetAwaiter().GetResult());
            }

            _connect(data);
        }