When a connection is closed with a message and closeCode <= 0, the message
is not sent at all. This is because of the test in line 382 of
WebSocketGeneratorRFC6455.java:

_outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_CLOSE,bytes,0,code>0?bytes.length:0);

Is this intended behavior? As a user, I expected that calling
connection.close(-1, "reason for closure") would populate a Javascript
ErrorEvent with:

wasClean: false
reason: "reason for closure"

Instead, reason is "". If this is intended behavior, I think the Javadoc
needs some elaboration; it reads:


org.eclipse.jetty.websocket.WebSocket.Connection

public void close(int closeCode, String message)

Close the connection with specific closeCode and message.

Parameters:
closeCode - The close code to send, or -1 for no close code
message - The message to send or null for no message


As implemented, message is never sent unless closeCode > 0.
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to