|
|
|
@ -287,18 +287,28 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
public HttpListenerWebSocketContext AcceptWebSocket (string protocol)
|
|
|
|
public HttpListenerWebSocketContext AcceptWebSocket (string protocol)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_websocketContext != null)
|
|
|
|
if (_websocketContext != null) {
|
|
|
|
throw new InvalidOperationException ("The accepting is already in progress.");
|
|
|
|
var msg = "The accepting is already in progress.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new InvalidOperationException (msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (protocol != null) {
|
|
|
|
if (protocol != null) {
|
|
|
|
if (protocol.Length == 0)
|
|
|
|
if (protocol.Length == 0) {
|
|
|
|
throw new ArgumentException ("An empty string.", "protocol");
|
|
|
|
var msg = "An empty string.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException (msg, "protocol");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!protocol.IsToken ())
|
|
|
|
if (!protocol.IsToken ()) {
|
|
|
|
throw new ArgumentException ("Contains an invalid character.", "protocol");
|
|
|
|
var msg = "It contains an invalid character.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException (msg, "protocol");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_websocketContext = new HttpListenerWebSocketContext (this, protocol);
|
|
|
|
_websocketContext = new HttpListenerWebSocketContext (this, protocol);
|
|
|
|
|
|
|
|
|
|
|
|
return _websocketContext;
|
|
|
|
return _websocketContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|