// Initializes a new client handler public void startClient(TcpClient inClientSocket, int inClientCode, ConnectionManager managerRef, Queue<LogEntry> queueRef = null) { // Set the manager of this handler to the provided reference manager = managerRef; // Set the socket in use to the provided reference clientSocket = inClientSocket; // Set the client code to the provided code clientCode = inClientCode; // Set the last interaction time to the current time lastReceived = DateTime.Now; // If a log queue was provided, set this class to generate log entries if (queueRef != null) { logQueue = queueRef; verbose = true; } // Set the main interaction loop to keep running keepRunning = true; // Create an SQL connection handler for this object to use sqlConnect = new SQLConnect(); // Create a new thread to handle server-client interaction clientThread = new Thread(Handle); // Start the thread clientThread.Start(); }
// Called when the start server button is clicked private void startServerButton_Click(object sender, RoutedEventArgs e) { // Disable the start server button startServerButton.IsEnabled = false; // Create a test connection to validate connection to SQL server Log("Creating SQL test connection..."); SQLConnect testConnection = new SQLConnect(logQueue); // Create a new connection manager and start it in a new thread Log("Initializing Connection Manager..."); connectionManager = new ConnectionManager(logQueue); connectionManagerThread = new Thread(connectionManager.Listen); connectionManagerThread.Start(); // Enable the close server button closeServerButton.IsEnabled = true; }