Пример #1
0
 @Override
 public final boolean trySend(WebDataMessage message) {
   if (!message.isBinary()) ctx.writeAndFlush(new TextWebSocketFrame(message.getStringBody()));
   else
     ctx.writeAndFlush(
         new BinaryWebSocketFrame(Unpooled.wrappedBuffer(message.getByteBufferBody())));
   return true;
 }
Пример #2
0
 @Override
 public final boolean trySend(WebDataMessage res) {
   final ByteBuf buf;
   final String stringBody = res.getStringBody();
   if (stringBody != null) {
     byte[] bs = stringBody.getBytes(encoding);
     buf = Unpooled.wrappedBuffer(bs);
   } else {
     buf = Unpooled.wrappedBuffer(res.getByteBufferBody());
   }
   ctx.writeAndFlush(buf);
   return true;
 }