private void HandleClient(object client) { TcpClient tcpClient = (TcpClient)client; NetworkStream clientStream = tcpClient.GetStream(); byte[] message = new byte[4096]; int bytesRead = 0; try { bool done = true; do { // blocks until a client sends a message bytesRead = clientStream.Read(message, 0, 4096); if (bytesRead == 0) { // the client has disconnected from the server tcpClient.Close(); return; } // log the http query Device.Logger.Add(new Log(LogType.HttpQuery, new string(Encoding.ASCII.GetChars(message, 0, bytesRead)))); //message has successfully been received SoapMethod usbMethod = new SoapMethod(message, bytesRead); IoStatus status = usbMethod.Execute(Device); if (status.error == USBError.SUCCESS) { done = !HttpParser.IsPartialResponse(usbMethod.HTTPStatus); clientStream.Write(status.buffer, 0, (int)status.size); } else { done = true; } // log the http response Device.Logger.Add(new Log(LogType.HttpResponse, new string(Encoding.ASCII.GetChars(status.buffer, 0, (int)status.size)))); } while (!done); } catch (Exception) { tcpClient.Close(); } }
public override void Visit(SoapMethod node) { this.action(node); }
public override void ExplicitVisit(SoapMethod fragment) { _fragments.Add(fragment); }