Refactored a few for WebSocket.cs

This commit is contained in:
sta 2015-08-09 11:27:42 +09:00
parent 5ceb4c4311
commit f780f536e2
2 changed files with 8 additions and 15 deletions

View File

@ -233,13 +233,6 @@ namespace WebSocketSharp
: null; : null;
} }
internal static string CheckIfConnectable (this WebSocketState state)
{
return state == WebSocketState.Open || state == WebSocketState.Closing
? "A WebSocket connection has already been established."
: null;
}
internal static string CheckIfOpen (this WebSocketState state) internal static string CheckIfOpen (this WebSocketState state)
{ {
return state == WebSocketState.Connecting return state == WebSocketState.Connecting

View File

@ -646,19 +646,19 @@ namespace WebSocketSharp
return sendHttpResponse (createHandshakeResponse ()); return sendHttpResponse (createHandshakeResponse ());
} }
private string checkIfAvailable (bool asServer, bool asConnected) private string checkIfAvailable (bool server, bool connected)
{ {
return !_client && !asServer return !server && !_client
? "This operation isn't available as a server." ? "This operation isn't available in the server."
: !asConnected : !connected && IsConnected
? _readyState.CheckIfConnectable () ? "This operation isn't available after the connection has been established."
: null; : null;
} }
private string checkIfCanAccept () private string checkIfCanAccept ()
{ {
return _client return _client
? "This operation isn't available as a client." ? "This operation isn't available in the client."
: _readyState.CheckIfCanAccept (); : _readyState.CheckIfCanAccept ();
} }
@ -1755,7 +1755,7 @@ namespace WebSocketSharp
/// Accepts the WebSocket connection request. /// Accepts the WebSocket connection request.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method isn't available as a client. /// This method isn't available in the client.
/// </remarks> /// </remarks>
public void Accept () public void Accept ()
{ {
@ -1779,7 +1779,7 @@ namespace WebSocketSharp
/// This method doesn't wait for the accept to be complete. /// This method doesn't wait for the accept to be complete.
/// </para> /// </para>
/// <para> /// <para>
/// This method isn't available as a client. /// This method isn't available in the client.
/// </para> /// </para>
/// </remarks> /// </remarks>
public void AcceptAsync () public void AcceptAsync ()