public static void doThreadWork() //must cast to object in order to use parameterized thread start { TcpClient client; WebRequest request; while (true) { client = threadPool.takeClient(); //constantly try to get a new client if (client == null) //if null client break this thread { break; } request = BuildRequest(client); //read from client and build a request if (request == null) //if not valid, find new client { continue; } bool found = false; foreach (WebService services in webServices) //try to find a valid service request { if ((request.URI.Split('/'))[1] == (services.ServiceURI.Split('/'))[1]) //*make sure this isn't out of range //grabs first word after request. if request was //GET /files /.... this would return 'files' { services.Handler(request); //call the handler for this request found = true; break; } } if (!found) //if you don't find it, send 404 to user { request.WriteNotFoundResponse("404 Page Not Found"); } } }
public static void doThreadWork() //must cast to object in order to use parameterized thread start { TcpClient client; WebRequest request; while (true) { client = threadPool.takeClient(); if (client == null) //if null client break this thread { break; } request = BuildRequest(client); if (request == null) { continue; } bool found = false; foreach (WebService services in webServices) { if (services.ServiceURI == request.URI) { services.Handler(request); found = true; break; } } if (!found) { request.WriteNotFoundResponse("404 Page Not Found"); } } }