Exemplo n.º 1
0
 private WebsocketMessage handlePartnerListRequest() {
   StringBuilder body = new StringBuilder();
   for (PartnerSite p : ipaddress2sitemap) body.append(p.getName()).append(",");
   WebsocketMessage wm = new WebsocketMessage();
   wm.setHeader("List of registered Partners");
   wm.setBody(body.substring(0, body.length() - 1));
   wm.setType("PARTNER-LIST");
   return wm;
 }
Exemplo n.º 2
0
 private void dispatchWebsocketRequest(ChannelHandlerContext ctx, WebSocketFrame frame) {
   WebsocketMessage wsRequest = WebsocketMessage.unmarshallFromJson(frame.getTextData());
   WebsocketMessage wsResponse = null;
   if (wsRequest.getType().equalsIgnoreCase("PARTNER-LIST")) {
     wsResponse = handlePartnerListRequest();
   }
   if (wsRequest.getType().equalsIgnoreCase("IP-EVENT-REQUEST")) {
     wsResponse = handleIpEventRequest();
   }
   if (wsResponse != null) {
     ctx.getChannel()
         .write(new DefaultWebSocketFrame(WebsocketMessage.marshallToJson(wsResponse)));
   }
 }