1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.util.Properties ; 14 import javax.servlet.ServletConfig ; 15 import javax.servlet.ServletOutputStream ; 16 import javax.servlet.ServletException ; 17 import javax.servlet.http.HttpServletRequest ; 18 import javax.servlet.http.HttpServletResponse ; 19 import org.openlaszlo.compiler.Canvas; 20 import org.openlaszlo.connection.*; 21 import org.apache.log4j.Logger; 22 23 public final class ResponderMESSAGE extends ResponderConnection 24 { 25 private static Logger mLogger = Logger.getLogger(ResponderMESSAGE.class); 26 27 protected void respondImpl(HttpServletRequest req, HttpServletResponse res, 28 Application app, int serial, String username) 29 throws IOException 30 { 31 String to = req.getParameter("to"); 32 String msg = req.getParameter("msg"); String range = req.getParameter("range"); 34 35 if (to==null||to.equals("")) { 36 respondWithErrorSWF(res, "missing 'to' parameter"); 37 return; 38 } 39 if (msg==null) { 40 respondWithErrorSWF(res, "missing 'msg' parameter" ); 41 return; 42 } 43 44 mLogger.debug("to='" + to + "',msg='" + msg + "',range='" + range + "',s=" + serial); 45 46 StringBuffer xmlResult = new StringBuffer (); 49 String wrapper = "<resultset s=\"0\">" + msg + "</resultset>"; 50 51 ConnectionGroup group = app.getConnectionGroup(); 52 int count = group.sendMessage(to, wrapper, range, xmlResult); 53 54 if (count > 0) { 55 respondWithStatusSWF(res, HttpServletResponse.SC_OK, 56 "message sent", xmlResult.toString(), serial); 57 } else { 58 String m = "message not sent: no one specified connected " + 59 "(range: " + range + ")"; 60 respondWithErrorSWF(res, m); 61 } 62 } 63 } 64 | Popular Tags |