[Modify] Throw exceptions
This commit is contained in:
parent
6cc77601dd
commit
4d510902b8
@ -815,19 +815,27 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public Dictionary<string, Dictionary<string, bool>> Broadping (string message)
|
public Dictionary<string, Dictionary<string, bool>> Broadping (string message)
|
||||||
{
|
{
|
||||||
if (message == null || message.Length == 0)
|
if (_state != ServerState.Start) {
|
||||||
return Broadping ();
|
var msg = "The current state of the manager is not Start.";
|
||||||
|
throw new InvalidOperationException (msg);
|
||||||
byte[] data = null;
|
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ??
|
|
||||||
WebSocket.CheckPingParameter (message, out data);
|
|
||||||
|
|
||||||
if (msg != null) {
|
|
||||||
_logger.Error (msg);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime);
|
if (message == null)
|
||||||
|
throw new ArgumentNullException ("message");
|
||||||
|
|
||||||
|
byte[] bytes;
|
||||||
|
if (!message.TryGetUTF8EncodedBytes (out bytes)) {
|
||||||
|
var msg = "It could not be UTF-8-encoded.";
|
||||||
|
throw new ArgumentException (msg, "message");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes.Length > 125) {
|
||||||
|
var msg = "Its size is greater than 125 bytes.";
|
||||||
|
throw new ArgumentOutOfRangeException ("message", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
var frame = WebSocketFrame.CreatePingFrame (bytes, false);
|
||||||
|
return broadping (frame.ToArray (), _waitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user