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