I am having a similar problem. I have installed the latest Glassfish v3
Prelude, and using Shing Wai's example to send messages via a servlet to the
clients using the DeliverResponse object. I have spent many hours trying to
upgrade to a later version of grizzly cometd but without success. My code
seems to execute without exception now, but the clients do not get the
messages sent by the servlet. I'm testing using NetBeans6.5, and several
MSIE7 clients. My 'broadcast message' code is below. Please let me know if
there is any other info or files that I might provide. Thank you for any
help.
// code within my TestServlet.java
.
.
protected void broadcast(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// joins add to the session map, leaves remove from the session map
Map channelMap =
(Map)getServletContext().getAttribute("channellist");
if(request.getParameter("broadcast")!=null){
String contextPath = "/dojoComet/cometd";
CometEngine engine = CometEngine.getEngine();
CometContext context = engine.getCometContext(contextPath);
DeliverResponse deliverResponse = new DeliverResponse();
ServletOutputStream out = response.getOutputStream();
// IVR sends ID, type, call ID, and NIDs
//String id = request.getParameter("client");
String id="Carl"; // using canned value for now
double callID = 12345678901234567890D;
String type = "sales_exchange";
String nid = "48U";
Map map = new HashMap();
map.put("id", id);
map.put("callID", callID);
map.put("type", type);
map.put("nid", nid);
Data data = new Data();
data.setMapData(map);
Set keys = channelMap.keySet();
Iterator it = keys.iterator();
String key = null;
out.println("<html><body>");
while(it.hasNext()){
// just use the key since key name and channel are same for
now
key = (String)channelMap.get(it.next());
deliverResponse.setChannel("/chat/"+key);
deliverResponse.setClientId(""); // fixes older cometd bug
deliverResponse.setData(data);
deliverResponse.setLast(true);
deliverResponse.setFollow(true);
try{
context.notify(deliverResponse);
out.println("message sent to "+key+"<br/>");
}catch(IllegalMonitorStateException imse){
imse.printStackTrace();
}finally{
out.println("</body></html>");
}
}
}
}
--
View this message in context: http://www.nabble.com/Problem-with-Bayeux-Servlet-Client-in-GlassFish-V3-tp20810461p20925149.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.