diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 12c0937d..b5a59a96 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -526,15 +526,20 @@ namespace WebSocketSharp.Server /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } + + if (data == null) + throw new ArgumentNullException ("data"); + + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } - var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); else