[Simpleweb-Support] Chat
Brought to you by:
niallg
From: berni <be...@t0...> - 2004-04-21 07:15:09
|
Hi! I looked at Simple and thought it would be a perfect solution to create a streaming HTML chat with it - because it does not use Servlets and because I can create a thread in the process method. I modified the HelloService, but the output appears only *after* the close has been issued, i.e. no streaming. Here is my experimental code in the process method: resp.set("Content-Type", "text/html"); out.println("<html><body><h1>Hello Service</h1>"); resp.commit(); //out.println("Hello World</body></html>"); //out.close(); new Thread(new Runnable(){ int counter = 0; public void run() { try { //service.forward(req, resp); while (true) { //final PrintStream out2 = resp.getPrintStream(); out.println("Hello World #" + (++counter) + "<br>"); out.flush(); //out.close(); resp.getOutputStream().flush(); resp.commit(); System.out.println("PRINTING.."); Thread.sleep(1000); if (counter == 10) { out.close(); break; } } }catch(Exception e){ // .... e.printStackTrace(System.err); } } }).start(); Is there any easy way to do streaming with Simple? TIA & Regards Bernhard |