Added the WebSocket.CheckSendParameter methods
This commit is contained in:
parent
f852a19746
commit
09a64d67be
@ -241,21 +241,6 @@ namespace WebSocketSharp
|
|||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string CheckIfValidSendData (this byte[] data)
|
|
||||||
{
|
|
||||||
return data == null ? "'data' is null." : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string CheckIfValidSendData (this FileInfo file)
|
|
||||||
{
|
|
||||||
return file == null ? "'file' is null." : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string CheckIfValidSendData (this string data)
|
|
||||||
{
|
|
||||||
return data == null ? "'data' is null." : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string CheckIfValidServicePath (this string path)
|
internal static string CheckIfValidServicePath (this string path)
|
||||||
{
|
{
|
||||||
return path == null || path.Length == 0
|
return path == null || path.Length == 0
|
||||||
|
@ -385,7 +385,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Broadcast (byte[] data)
|
public void Broadcast (byte[] data)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -405,7 +407,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Broadcast (string data)
|
public void Broadcast (string data)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -434,7 +438,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void BroadcastAsync (byte[] data, Action completed)
|
public void BroadcastAsync (byte[] data, Action completed)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -462,7 +468,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void BroadcastAsync (string data, Action completed)
|
public void BroadcastAsync (string data, Action completed)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
|
@ -393,7 +393,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Broadcast (byte[] data)
|
public void Broadcast (byte[] data)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -413,7 +415,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void Broadcast (string data)
|
public void Broadcast (string data)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -442,7 +446,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void BroadcastAsync (byte[] data, Action completed)
|
public void BroadcastAsync (byte[] data, Action completed)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
@ -470,7 +476,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void BroadcastAsync (string data, Action completed)
|
public void BroadcastAsync (string data, Action completed)
|
||||||
{
|
{
|
||||||
var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData ();
|
var msg = _state.CheckIfAvailable (false, true, false) ??
|
||||||
|
WebSocket.CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return;
|
return;
|
||||||
|
@ -1625,6 +1625,21 @@ namespace WebSocketSharp
|
|||||||
return bytes.Length > 125 ? "A message has greater than the allowable max size." : null;
|
return bytes.Length > 125 ? "A message has greater than the allowable max size." : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string CheckSendParameter (byte[] data)
|
||||||
|
{
|
||||||
|
return data == null ? "'data' is null." : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string CheckSendParameter (FileInfo file)
|
||||||
|
{
|
||||||
|
return file == null ? "'file' is null." : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string CheckSendParameter (string data)
|
||||||
|
{
|
||||||
|
return data == null ? "'data' is null." : null;
|
||||||
|
}
|
||||||
|
|
||||||
// As server
|
// As server
|
||||||
internal void Close (HttpResponse response)
|
internal void Close (HttpResponse response)
|
||||||
{
|
{
|
||||||
@ -2249,7 +2264,7 @@ namespace WebSocketSharp
|
|||||||
public void Send (byte[] data)
|
public void Send (byte[] data)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
data.CheckIfValidSendData ();
|
CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -2270,7 +2285,7 @@ namespace WebSocketSharp
|
|||||||
public void Send (FileInfo file)
|
public void Send (FileInfo file)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
file.CheckIfValidSendData ();
|
CheckSendParameter (file);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -2291,7 +2306,7 @@ namespace WebSocketSharp
|
|||||||
public void Send (string data)
|
public void Send (string data)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
data.CheckIfValidSendData ();
|
CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -2320,7 +2335,7 @@ namespace WebSocketSharp
|
|||||||
public void SendAsync (byte[] data, Action<bool> completed)
|
public void SendAsync (byte[] data, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
data.CheckIfValidSendData ();
|
CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -2350,7 +2365,7 @@ namespace WebSocketSharp
|
|||||||
public void SendAsync (FileInfo file, Action<bool> completed)
|
public void SendAsync (FileInfo file, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
file.CheckIfValidSendData ();
|
CheckSendParameter (file);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -2379,7 +2394,7 @@ namespace WebSocketSharp
|
|||||||
public void SendAsync (string data, Action<bool> completed)
|
public void SendAsync (string data, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
||||||
data.CheckIfValidSendData ();
|
CheckSendParameter (data);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user