Renamed the CheckIfValidCloseParameters methods to the CheckCloseParameters methods

This commit is contained in:
sta 2015-05-04 15:48:18 +09:00
parent 79ea2b74c7
commit 531eefac17
3 changed files with 14 additions and 39 deletions

View File

@ -757,9 +757,7 @@ namespace WebSocketSharp.Server
public void Stop (ushort code, string reason) public void Stop (ushort code, string reason)
{ {
lock (_sync) { lock (_sync) {
var msg = _state.CheckIfStart () ?? var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false);
WebSocket.CheckIfValidCloseParameters (code, reason, false);
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -795,9 +793,7 @@ namespace WebSocketSharp.Server
public void Stop (CloseStatusCode code, string reason) public void Stop (CloseStatusCode code, string reason)
{ {
lock (_sync) { lock (_sync) {
var msg = _state.CheckIfStart () ?? var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false);
WebSocket.CheckIfValidCloseParameters (code, reason, false);
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;

View File

@ -842,9 +842,7 @@ namespace WebSocketSharp.Server
public void Stop (ushort code, string reason) public void Stop (ushort code, string reason)
{ {
lock (_sync) { lock (_sync) {
var msg = _state.CheckIfStart () ?? var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false);
WebSocket.CheckIfValidCloseParameters (code, reason, false);
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -879,9 +877,7 @@ namespace WebSocketSharp.Server
public void Stop (CloseStatusCode code, string reason) public void Stop (CloseStatusCode code, string reason)
{ {
lock (_sync) { lock (_sync) {
var msg = _state.CheckIfStart () ?? var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false);
WebSocket.CheckIfValidCloseParameters (code, reason, false);
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;

View File

@ -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);