eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.25k stars 2.06k forks source link

Write buffer text message #2756

Open YongGang opened 5 years ago

YongGang commented 5 years ago

In WebSocketImplBase, the writeTextMessage method accept a String as input, then convert it to Buffer internally. I'd like to add a method which accept Buffer data but send out as FrameType.TEXT Something like the following:

  @Override
  public S writeTextMessage(Buffer textBuffer) {
    synchronized (conn) {
      checkClosed();
      writePartialMessage(FrameType.TEXT, textBuffer, 0);
      return (S) this;
    }
  }

It's for the performance, in our case we already have a Buffer, it will be wasted to convert it to String then Vertx convert the String to Buffer again before sending out.

vietj commented 5 years ago

feel free to make a PR with a test @YongGang