private void AcceptConnections() { TcpClient objConnection; Client objClient; Processor objProcessor = null; int intArrIndex; marrClients=new System.Collections.ArrayList(); while (true) { // Accept Client Connection and start Communicator instance objConnection = mobjServer.AcceptTcpClient(); // RaiseLocalEvent(Me, "New Client Connected") // Create Processor instance // TODO - Would need dynamic assembly load HERE if going about this way // objProcessor = new IProcessor(); /* // Wire Processor instance to call Server copy of method for OnCallback objProcessor.OnCallback -= new Processor.ParentCallback(objProcessor.InvokeParentCallback); objProcessor.OnCallback += new Processor.ParentCallback(this.InvokeParentCallback); */ // Create Child Client instance objClient = new Client(objConnection, objProcessor); // Wire child Client class to call Server copy of method for OnCallback objClient.OnCallback -= new Client.ParentCallback(objClient.InvokeParentCallback); objClient.OnCallback += new Client.ParentCallback(this.InvokeParentCallback); // Wire child Client class to Pass Exceptions up to Server copy objClient.OnException -= new Client.HandleException(objClient.InvokeHandleException); objClient.OnException += new Client.HandleException(this.InvokeHandleException); // Add child Client instance to Array and start work on Client connection intArrIndex = marrClients.Add(objClient); objClient.Start(); // Start background Thread that polls for Redundant Clients MonitorClients(); } }
private void AcceptConnections() { TcpClient objConnection; Client objClient; Processor objProcessor = null; int intArrIndex; bool blnForwardClientRequests = false; marrClients=new System.Collections.ArrayList(); while (true) // Put this on a timer if more resources needed between times { // Accept Client Connection and start Communicator instance objConnection = mobjServer.AcceptTcpClient(); if (objConnection != null) { Logging.WriteToLog(this, "New Client Connected"); if (ConfigurationManager.AppSettings["ForwardClientRequests"] != null) { blnForwardClientRequests = bool.Parse(ConfigurationManager.AppSettings["ForwardClientRequests"]); } if (blnForwardClientRequests == false) { // Create Processor instance objProcessor = new Processor(); // new Processor(mobjSocketConnection) // Wire Processor instance to call Server copy of method for OnCallback objProcessor.OnCallback -= new Processor.ParentCallback(objProcessor.InvokeParentCallback); objProcessor.OnCallback += new Processor.ParentCallback(this.InvokeParentCallback); } // Create Child Client instance objClient = new Client(objConnection, objProcessor); // Pass non empty Processor instance for immediate work // Wire child Client class to call Server copy of method for OnCallback objClient.OnCallback -= new Client.ParentCallback(objClient.InvokeParentCallback); objClient.OnCallback += new Client.ParentCallback(this.InvokeParentCallback); // Wire child Client class to Pass Exceptions up to Server copy objClient.OnException -= new Client.HandleException(objClient.InvokeHandleException); objClient.OnException += new Client.HandleException(this.InvokeHandleException); // Add child Client instance to Array and start work on Client connection intArrIndex = marrClients.Add(objClient); objClient.Start(); //((Client) marrClients(intArrIndex)).Start(); } } }