Added accept method

This commit is contained in:
sta 2015-08-06 17:15:02 +09:00
parent 776fee9170
commit 745da21631
2 changed files with 33 additions and 0 deletions

View File

@ -201,6 +201,13 @@ namespace WebSocketSharp
}
}
internal static string CheckIfCanAccept (this WebSocketState state)
{
return state != WebSocketState.Connecting
? "This operation has already been done."
: null;
}
internal static string CheckIfCanRead (this Stream stream)
{
return stream == null

View File

@ -592,6 +592,32 @@ namespace WebSocketSharp
#region Private Methods
// As server
private bool accept ()
{
lock (_forConn) {
var msg = _readyState.CheckIfCanAccept ();
if (msg != null) {
_logger.Error (msg);
error ("An error has occurred in accepting.", null);
return false;
}
try {
if (acceptHandshake ()) {
_readyState = WebSocketState.Open;
return true;
}
}
catch (Exception ex) {
processException (ex, "An exception has occurred while accepting.");
}
return false;
}
}
// As server
private bool acceptHandshake ()
{