-
-
Notifications
You must be signed in to change notification settings - Fork 202
Description
Hi, I found these methods in WebSocket to be confusing
jooby/jooby/src/main/java/io/jooby/WebSocket.java
Lines 228 to 266 in 27315c4
| /** | |
| * Send a text message to client. | |
| * | |
| * @param message Text Message. | |
| * @return This websocket. | |
| */ | |
| default WebSocket send(@NonNull byte[] message) { | |
| return send(message, WriteCallback.NOOP); | |
| } | |
| /** | |
| * Send a text message to client. | |
| * | |
| * @param message Text Message. | |
| * @param callback Write callback. | |
| * @return This websocket. | |
| */ | |
| default WebSocket send(byte[] message, @NonNull WriteCallback callback) { | |
| return send(ByteBuffer.wrap(message), callback); | |
| } | |
| /** | |
| * Send a text message to client. | |
| * | |
| * @param message Text message. | |
| * @return This instance. | |
| */ | |
| default WebSocket send(@NonNull ByteBuffer message) { | |
| return send(message, WriteCallback.NOOP); | |
| } | |
| /** | |
| * Send a text message to client. | |
| * | |
| * @param message Text message. | |
| * @param callback Write callback. | |
| * @return This instance. | |
| */ | |
| WebSocket send(@NonNull ByteBuffer message, @NonNull WriteCallback callback); |
I don't see the point of having methods which convert binary parameter to string value and send a text message. if i have binary, why would i send text websocket message? at least i would convert it myself in that case, and specify my own way of converting. for example the javadoc does not say what type of conversion it uses (it decodes bytes to string using utf-8). i think these methods only confuse first time users, maybe they should be deprecated so that users notice sendBinary earlier. sure, the javadoc is clear that it sends text but i still consider it a bit odd that these methods exist at all, i have not seen this kind of methods in any other websocket library