|
|
|
@ -2613,22 +2613,25 @@ namespace WebSocketSharp
|
|
|
|
throw new ArgumentException (msg, "code");
|
|
|
|
throw new ArgumentException (msg, "code");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!reason.IsNullOrEmpty ()) {
|
|
|
|
if (reason.IsNullOrEmpty ()) {
|
|
|
|
if (code == 1005) {
|
|
|
|
close (code, String.Empty);
|
|
|
|
var msg = "1005 cannot be used.";
|
|
|
|
return;
|
|
|
|
throw new ArgumentException (msg, "code");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bytes;
|
|
|
|
if (code == 1005) {
|
|
|
|
if (!reason.TryGetUTF8EncodedBytes (out bytes)) {
|
|
|
|
var msg = "1005 cannot be used.";
|
|
|
|
var msg = "It could not be UTF-8-encoded.";
|
|
|
|
throw new ArgumentException (msg, "code");
|
|
|
|
throw new ArgumentException (msg, "reason");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes.Length > 123) {
|
|
|
|
byte[] bytes;
|
|
|
|
var msg = "Its size is greater than 123 bytes.";
|
|
|
|
if (!reason.TryGetUTF8EncodedBytes (out bytes)) {
|
|
|
|
throw new ArgumentOutOfRangeException ("reason", msg);
|
|
|
|
var msg = "It could not be UTF-8-encoded.";
|
|
|
|
}
|
|
|
|
throw new ArgumentException (msg, "reason");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bytes.Length > 123) {
|
|
|
|
|
|
|
|
var msg = "Its size is greater than 123 bytes.";
|
|
|
|
|
|
|
|
throw new ArgumentOutOfRangeException ("reason", msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
close (code, reason);
|
|
|
|
close (code, reason);
|
|
|
|
|