Exemple #1
0
 /// <summary>
 /// On client connected.
 /// </summary>
 /// <param name="context">The client context.</param>
 private void ClientConnected(Nequeo.Net.Provider.ISingleContextMux context)
 {
     // If this is a secure connection.
     if (context.UseSslConnection && !context.IsSslAuthenticated)
     {
         // Start tls if not active.
     }
 }
Exemple #2
0
        /// <summary>
        /// On client connected.
        /// </summary>
        /// <param name="context">The client context.</param>
        private void ClientConnected(Nequeo.Net.Provider.ISingleContextMux context)
        {
            // Make the unique id the same as the connection ID.
            context.UniqueIdentifier = context.ConnectionID;

            // Add the client.
            ClientConnectedEx(context);
        }
Exemple #3
0
 /// <summary>
 /// On client connected.
 /// </summary>
 /// <param name="context">The client context.</param>
 private void ClientConnected(Nequeo.Net.Provider.ISingleContextMux context)
 {
     // If this is a secure connection.
     if (context.UseSslConnection && !context.IsSslAuthenticated)
     {
         try
         {
             // Start the ssl negotiations.
             context.BeginSslNegotiation();
         }
         catch { }
     }
 }
Exemple #4
0
        /// <summary>
        /// On client connected.
        /// </summary>
        /// <param name="context">The client context.</param>
        private async void ClientConnectedEx(Nequeo.Net.Provider.ISingleContextMux context)
        {
            await Nequeo.Threading.AsyncOperationResult <bool> .
            RunTask(() =>
            {
                bool sslNegComplete = true;

                // If this is a secure connection.
                if (context.UseSslConnection && !context.IsSslAuthenticated)
                {
                    try
                    {
                        // Start the ssl negotiations.
                        context.BeginSslNegotiation();
                    }
                    catch
                    {
                        // Negotiation has failed.
                        sslNegComplete = false;
                    }
                }

                // If the ssl negotiation has completed or non ssl connection
                // add the client to the connection base.
                if (sslNegComplete)
                {
                    lock (_lockObject)
                    {
                        try
                        {
                            // Create a new connection context.
                            Nequeo.Net.Data.ConnectionContext conn = new Data.ConnectionContext();

                            // Get the name of the server this client will connect to.
                            // Get the server that has the least amount of connections.
                            int minimum = _loadServers.servers.Min(u => u.count);
                            Data.contextServer balanceServer = _loadServers.servers.First(u => u.count <= minimum);
                            balanceServer.count += 1;

                            // Create a new connection to a server.
                            Nequeo.Net.NetClient client = new NetClient(balanceServer.host, balanceServer.port);
                            client.OnNetContext        += client_OnNetContext;
                            client.UseSslConnection     = balanceServer.secure;
                            client.Connect();

                            // Make the client connection ID the same as the
                            // client context connection ID.
                            client.ConnectionID = context.ConnectionID;

                            // Assign the values.
                            conn.Client            = client;
                            conn.LoadBalanceServer = balanceServer.name;

                            // Add the client.
                            _clients.Add(context.ConnectionID, conn);
                        }
                        catch { }
                    }
                }
                else
                {
                    // Close the connection.
                    context.Close();
                }
            });
        }