コード例 #1
0
ファイル: PlayHandler.java プロジェクト: robfig/play
 private void websocketFrameReceived(
     final ChannelHandlerContext ctx, WebSocketFrame webSocketFrame) {
   Http.Inbound inbound = channels.get(ctx);
   if (webSocketFrame.isBinary()) {
     inbound._received(new Http.WebSocketFrame(webSocketFrame.getBinaryData().array()));
   } else {
     inbound._received(new Http.WebSocketFrame(webSocketFrame.getTextData()));
   }
 }
コード例 #2
0
ファイル: OlafWebsocketServer.java プロジェクト: apeglow/olaf
 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)));
   }
 }
コード例 #3
0
 private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
   // Send the uppercased string back.
   ctx.getChannel().write(new DefaultWebSocketFrame(frame.getTextData().toUpperCase()));
 }