|
|
|
@ -1560,7 +1560,7 @@ namespace WebSocketSharp
|
|
|
|
|
|
|
|
|
|
|
|
#region Internal Methods
|
|
|
|
#region Internal Methods
|
|
|
|
|
|
|
|
|
|
|
|
internal static string CheckIfValidCloseParameters (ushort code, string reason, bool client)
|
|
|
|
internal static string CheckCloseParameters (ushort code, string reason, bool client)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return !code.IsCloseStatusCode ()
|
|
|
|
return !code.IsCloseStatusCode ()
|
|
|
|
? "An invalid close status code."
|
|
|
|
? "An invalid close status code."
|
|
|
|
@ -1575,8 +1575,7 @@ namespace WebSocketSharp
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static string CheckIfValidCloseParameters (
|
|
|
|
internal static string CheckCloseParameters (CloseStatusCode code, string reason, bool client)
|
|
|
|
CloseStatusCode code, string reason, bool client)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return code == CloseStatusCode.NoStatus
|
|
|
|
return code == CloseStatusCode.NoStatus
|
|
|
|
? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null)
|
|
|
|
? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null)
|
|
|
|
@ -1767,9 +1766,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void Close (ushort code)
|
|
|
|
public void Close (ushort code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
|
|
|
CheckIfValidCloseParameters (code, null, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1796,9 +1793,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void Close (CloseStatusCode code)
|
|
|
|
public void Close (CloseStatusCode code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
|
|
|
CheckIfValidCloseParameters (code, null, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1832,9 +1827,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void Close (ushort code, string reason)
|
|
|
|
public void Close (ushort code, string reason)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
|
|
|
CheckIfValidCloseParameters (code, reason, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1868,9 +1861,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void Close (CloseStatusCode code, string reason)
|
|
|
|
public void Close (CloseStatusCode code, string reason)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
|
|
|
CheckIfValidCloseParameters (code, reason, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1924,9 +1915,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void CloseAsync (ushort code)
|
|
|
|
public void CloseAsync (ushort code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
|
|
|
CheckIfValidCloseParameters (code, null, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1956,9 +1945,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void CloseAsync (CloseStatusCode code)
|
|
|
|
public void CloseAsync (CloseStatusCode code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
|
|
|
CheckIfValidCloseParameters (code, null, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -1997,9 +1984,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void CloseAsync (ushort code, string reason)
|
|
|
|
public void CloseAsync (ushort code, string reason)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
|
|
|
CheckIfValidCloseParameters (code, reason, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
@ -2039,9 +2024,7 @@ namespace WebSocketSharp
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public void CloseAsync (CloseStatusCode code, string reason)
|
|
|
|
public void CloseAsync (CloseStatusCode code, string reason)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var msg = _readyState.CheckIfClosable () ??
|
|
|
|
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
|
|
|
CheckIfValidCloseParameters (code, reason, _client);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
_logger.Error (msg);
|
|
|
|
_logger.Error (msg);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
error ("An error has occurred in closing the connection.", null);
|
|
|
|
|