Added the internal Ext.CheckIfCanClose (WebSocketState) method
This commit is contained in:
parent
f780f536e2
commit
dce49c037f
@ -208,6 +208,13 @@ namespace WebSocketSharp
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfCanClose (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.Closing || state == WebSocketState.Closed
|
||||
? String.Format ("This operation isn't available ({0}).", state)
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfCanConnect (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.Open || state == WebSocketState.Closing
|
||||
@ -224,15 +231,6 @@ namespace WebSocketSharp
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfClosable (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.Closing
|
||||
? "While closing the WebSocket connection."
|
||||
: state == WebSocketState.Closed
|
||||
? "The WebSocket connection has already been closed."
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfOpen (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.Connecting
|
||||
|
@ -1806,7 +1806,7 @@ namespace WebSocketSharp
|
||||
/// </summary>
|
||||
public void Close ()
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable ();
|
||||
var msg = _readyState.CheckIfCanClose ();
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1830,7 +1830,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void Close (ushort code)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1857,7 +1857,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void Close (CloseStatusCode code)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1891,7 +1891,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void Close (ushort code, string reason)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1925,7 +1925,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void Close (CloseStatusCode code, string reason)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1950,7 +1950,7 @@ namespace WebSocketSharp
|
||||
/// </remarks>
|
||||
public void CloseAsync ()
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable ();
|
||||
var msg = _readyState.CheckIfCanClose ();
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -1979,7 +1979,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void CloseAsync (ushort code)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -2009,7 +2009,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void CloseAsync (CloseStatusCode code)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -2048,7 +2048,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void CloseAsync (ushort code, string reason)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
@ -2088,7 +2088,7 @@ namespace WebSocketSharp
|
||||
/// </param>
|
||||
public void CloseAsync (CloseStatusCode code, string reason)
|
||||
{
|
||||
var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client);
|
||||
var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client);
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
error ("An error has occurred in closing the connection.", null);
|
||||
|
Loading…
Reference in New Issue
Block a user