Added accept method
This commit is contained in:
parent
776fee9170
commit
745da21631
@ -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
|
||||
|
@ -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 ()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user