[Modify] Throw exceptions
This commit is contained in:
parent
bd1d1fd922
commit
a5eccd5442
@ -565,15 +565,18 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Broadcast (string data)
|
public void Broadcast (string data)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ??
|
if (_state != ServerState.Start) {
|
||||||
WebSocket.CheckSendParameter (data);
|
var msg = "The current state of the manager is not Start.";
|
||||||
|
throw new InvalidOperationException (msg);
|
||||||
if (msg != null) {
|
|
||||||
_logger.Error (msg);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var bytes = data.UTF8Encode ();
|
if (data == null)
|
||||||
|
throw new ArgumentNullException ("data");
|
||||||
|
|
||||||
|
byte[] bytes;
|
||||||
|
if (!data.TryGetUTF8EncodedBytes (out bytes))
|
||||||
|
throw new ArgumentException ("It could not be UTF-8-encoded.", "data");
|
||||||
|
|
||||||
if (bytes.LongLength <= WebSocket.FragmentLength)
|
if (bytes.LongLength <= WebSocket.FragmentLength)
|
||||||
broadcast (Opcode.Text, bytes, null);
|
broadcast (Opcode.Text, bytes, null);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user