Modified the WebSocket class, fix for 'No Status Code' for the close
This commit is contained in:
parent
1bb7775a7e
commit
f072485b83
@ -1694,9 +1694,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Close (ushort code)
|
public void Close (ushort code)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseStatusCode ();
|
||||||
code.CheckIfValidCloseStatusCode ();
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1704,6 +1702,11 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
close (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
close (new CloseEventArgs (code), send, send);
|
close (new CloseEventArgs (code), send, send);
|
||||||
}
|
}
|
||||||
@ -1726,6 +1729,11 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
close (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
close (new CloseEventArgs (code), send, send);
|
close (new CloseEventArgs (code), send, send);
|
||||||
}
|
}
|
||||||
@ -1748,11 +1756,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Close (ushort code, string reason)
|
public void Close (ushort code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
|
||||||
code.CheckIfValidCloseStatusCode () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1760,8 +1764,13 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
close (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
close (e, send, send);
|
close (new CloseEventArgs (code, reason), send, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1781,10 +1790,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Close (CloseStatusCode code, string reason)
|
public void Close (CloseStatusCode code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1792,8 +1798,13 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
close (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
close (e, send, send);
|
close (new CloseEventArgs (code, reason), send, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1833,9 +1844,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void CloseAsync (ushort code)
|
public void CloseAsync (ushort code)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseStatusCode ();
|
||||||
code.CheckIfValidCloseStatusCode ();
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1843,6 +1852,11 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
closeAsync (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
closeAsync (new CloseEventArgs (code), send, send);
|
closeAsync (new CloseEventArgs (code), send, send);
|
||||||
}
|
}
|
||||||
@ -1868,6 +1882,11 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
closeAsync (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
closeAsync (new CloseEventArgs (code), send, send);
|
closeAsync (new CloseEventArgs (code), send, send);
|
||||||
}
|
}
|
||||||
@ -1894,11 +1913,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void CloseAsync (ushort code, string reason)
|
public void CloseAsync (ushort code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
|
||||||
code.CheckIfValidCloseStatusCode () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1906,8 +1921,13 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
closeAsync (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
closeAsync (e, send, send);
|
closeAsync (new CloseEventArgs (code, reason), send, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1933,10 +1953,7 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void CloseAsync (CloseStatusCode code, string reason)
|
public void CloseAsync (CloseStatusCode code, string reason)
|
||||||
{
|
{
|
||||||
CloseEventArgs e = null;
|
var msg = _readyState.CheckIfClosable () ?? code.CheckIfValidCloseParameters (reason);
|
||||||
var msg = _readyState.CheckIfClosable () ??
|
|
||||||
(e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
|
|
||||||
|
|
||||||
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);
|
||||||
@ -1944,8 +1961,13 @@ namespace WebSocketSharp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code.IsNoStatusCode ()) {
|
||||||
|
closeAsync (new CloseEventArgs (), true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var send = !code.IsReserved ();
|
var send = !code.IsReserved ();
|
||||||
closeAsync (e, send, send);
|
closeAsync (new CloseEventArgs (code, reason), send, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user