Tag: 氛围

无法在WebSocketHandlerAdapter上播放

我正在建立一个基于氛围的websocket概念certificate。 创建了一个订阅2个频道的javascript客户端,并在服务器上创建了创建两个广播公司并继续发送数据的线程,但是我无法在客户端上获取数据。 有没有办法检查邮件是否卡在服务器端或客户端? 我在哪儿丢球吗? 🙂 这就是我现在所拥有的: PublishServerState – 创建广播公司并发送消息 import javax.servlet.http.HttpServlet; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.atmosphere.cpr.AtmosphereFramework; import org.atmosphere.cpr.Broadcaster; import org.atmosphere.cpr.BroadcasterFactory; // TODO desligar os threads quando a app esta desligando public class PublishServerState extends HttpServlet { private static final long serialVersionUID = 1L; public static String value1 = “um-“; public static String […]

已建立大气sockets但未接收/发送数据

我正在关注Atmosphere 教程以获得基本的聊天应用程序设置。 目前,当运行javascript时,它似乎能够使用Web套接字建立与服务器的连接。 我在Chrome控制台中获得以下内容: Invoking executeWebSocket core.js:2298 Using URL: ws://localhost:8080/web-transport/chat?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.1&X-Atmosphere-Transport=websocket&X-Cache-Date=0&Content-Type=application/json core.js:2298 Websocket successfully opened 但是,当我尝试发布数据(subSocket.push(…))时似乎没有任何事情发生。 我已经尝试调试AtmosphereHandlerService但它似乎永远不会被命中(并且没有生成日志。 我错过了什么会导致这种情况? 到目前为止,我有以下内容: web.xml中 AtmosphereServlet AtmosphereServlet AtmosphereServlet AtmosphereServlet org.atmosphere.cpr.AtmosphereServlet <!– true –> AtmosphereServlet /chat/* ChatAtmosphereHandler.java @AtmosphereHandlerService(path = “/chat”) public class ChatAtmosphereHandler implements AtmosphereHandler { public void onRequest(AtmosphereResource resource) throws IOException { AtmosphereRequest request = resource.getRequest(); if (request.getMethod().equalsIgnoreCase(“GET”)) { resource.suspend(); } […]

MultivaluedMapexception

我试图运行一个大气样本,但当我运行Restful Web服务时它给我跟随错误,我想因为下面的代码它生成错误,我不知道有什么问题我使用glassfish 3和Netbeans IDE,这是示例链接 @Broadcast({XSSHtmlFilter.class, JsonpFilter.class}) @Consumes(“application/x-www-form-urlencoded”) @POST public String publishMessage(MultivaluedMap form) { String action = form.getFirst(“action”); String name = form.getFirst(“name”); if (“login”.equals(action)) { return (“System Message” + “__” + name + ” has joined.”); } else if (“post”.equals(action)) { return name + “__” + form.getFirst(“message”); } else { throw new WebApplicationException(422); } } INFO: […]

WebSockets – 创建渠道和推送数据的正确方法

我有一个场景,我想通知我的网站用户,有人评论了他们也评论过的文章。 这有点像当有人回答问题时SO通知我的方式! 服务器端,我坚持评论,然后查找评论同一篇文章的所有用户。 然后我播出(我正在使用Atmosphere): PushContext pushContext = PushContextFactory.getDefault().getPushContext(); for(User u : users){ // channel name, message pushContext.push(“/user_” + u.id, “someone commented! blah blah”); } 我正在广播的“频道”是用户的“自己的”频道,因为我不希望每个用户都收到通知。 我在频道名称中使用用户ID来实现此目的。 这是确保只有相关用户得到通知的正确方法吗? 我想我还想再做两件事: 只推送我认为仍然在线的用户。 如果他们不在线,则浪费资源推动他们。 加密邮件,因为否则任何人都可以收听我的邮件,如果他们知道我的用户ID。 还有什么我需要考虑的吗?