int closeCode;
String closeReasonString;
final byte[] data = frame.getPayloadData();
if (data.length < 2) {
throw new ProtocolError("Closing wrappedFrame payload, if present, must be a minimum of 2 bytes in length") {
// autobahn test suite, test 7.3.1
@Override
public int getClosingCode() {
if (data.length == 0) {
return 1000;
} else {
return super.getClosingCode();
}
}
};
} else {
closeCode = (int) Utils.toLong(data, 0, 2);
if (closeCode < 1000 || closeCode == 1004 || closeCode == 1005 || closeCode == 1006 || (closeCode > 1011 && closeCode < 3000) || closeCode > 4999) {
throw new ProtocolError("Illegal status code: " + closeCode);
}
if (data.length > 2) {
closeReasonString = utf8Decode(data);
} else {
closeReasonString = null;