Added the WebSocket.CheckSendParameters method
This commit is contained in:
parent
09a64d67be
commit
ddb5819a0e
@ -222,15 +222,6 @@ namespace WebSocketSharp
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfCanRead (this Stream stream)
|
||||
{
|
||||
return stream == null
|
||||
? "'stream' is null."
|
||||
: !stream.CanRead
|
||||
? "'stream' cannot be read."
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfValidProtocols (this string[] protocols)
|
||||
{
|
||||
return protocols.Contains (
|
||||
|
@ -503,8 +503,7 @@ namespace WebSocketSharp.Server
|
||||
public void BroadcastAsync (Stream stream, int length, Action completed)
|
||||
{
|
||||
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||
stream.CheckIfCanRead () ??
|
||||
(length < 1 ? "'length' is less than 1." : null);
|
||||
WebSocket.CheckSendParameters (stream, length);
|
||||
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
|
@ -511,8 +511,7 @@ namespace WebSocketSharp.Server
|
||||
public void BroadcastAsync (Stream stream, int length, Action completed)
|
||||
{
|
||||
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||
stream.CheckIfCanRead () ??
|
||||
(length < 1 ? "'length' is less than 1." : null);
|
||||
WebSocket.CheckSendParameters (stream, length);
|
||||
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
|
@ -1640,6 +1640,17 @@ namespace WebSocketSharp
|
||||
return data == null ? "'data' is null." : null;
|
||||
}
|
||||
|
||||
internal static string CheckSendParameters (Stream stream, int length)
|
||||
{
|
||||
return stream == null
|
||||
? "'stream' is null."
|
||||
: !stream.CanRead
|
||||
? "'stream' cannot be read."
|
||||
: length < 1
|
||||
? "'length' is less than 1."
|
||||
: null;
|
||||
}
|
||||
|
||||
// As server
|
||||
internal void Close (HttpResponse response)
|
||||
{
|
||||
@ -2427,8 +2438,7 @@ namespace WebSocketSharp
|
||||
public void SendAsync (Stream stream, int length, Action<bool> completed)
|
||||
{
|
||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||
stream.CheckIfCanRead () ??
|
||||
(length < 1 ? "'length' is less than 1." : null);
|
||||
CheckSendParameters (stream, length);
|
||||
|
||||
if (msg != null) {
|
||||
_logger.Error (msg);
|
||||
|
Loading…
Reference in New Issue
Block a user