Added the WebSocket.CheckPingParameter method, and removed the Ext.CheckIfValidControlData method
This commit is contained in:
parent
531eefac17
commit
dee36926ae
@ -251,13 +251,6 @@ namespace WebSocketSharp
|
|||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string CheckIfValidControlData (this byte[] data, string paramName)
|
|
||||||
{
|
|
||||||
return data.Length > 125
|
|
||||||
? String.Format ("'{0}' has greater than the allowable max size.", paramName)
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string CheckIfValidProtocols (this string[] protocols)
|
internal static string CheckIfValidProtocols (this string[] protocols)
|
||||||
{
|
{
|
||||||
return protocols.Contains (
|
return protocols.Contains (
|
||||||
|
@ -566,10 +566,8 @@ namespace WebSocketSharp.Server
|
|||||||
if (message == null || message.Length == 0)
|
if (message == null || message.Length == 0)
|
||||||
return Broadping ();
|
return Broadping ();
|
||||||
|
|
||||||
byte[] data = null;
|
byte[] data;
|
||||||
var msg = _state.CheckIfStart () ??
|
var msg = _state.CheckIfStart () ?? WebSocket.CheckPingParameter (message, out data);
|
||||||
(data = Encoding.UTF8.GetBytes (message)).CheckIfValidControlData ("message");
|
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return null;
|
return null;
|
||||||
|
@ -571,10 +571,8 @@ namespace WebSocketSharp.Server
|
|||||||
if (message == null || message.Length == 0)
|
if (message == null || message.Length == 0)
|
||||||
return Broadping ();
|
return Broadping ();
|
||||||
|
|
||||||
byte[] data = null;
|
byte[] data;
|
||||||
var msg = _state.CheckIfStart () ??
|
var msg = _state.CheckIfStart () ?? WebSocket.CheckPingParameter (message, out data);
|
||||||
(data = Encoding.UTF8.GetBytes (message)).CheckIfValidControlData ("message");
|
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
return null;
|
return null;
|
||||||
|
@ -1588,6 +1588,12 @@ namespace WebSocketSharp
|
|||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string CheckPingParameter (string message, out byte[] bytes)
|
||||||
|
{
|
||||||
|
bytes = Encoding.UTF8.GetBytes (message);
|
||||||
|
return bytes.Length > 125 ? "A message has greater than the allowable max size." : null;
|
||||||
|
}
|
||||||
|
|
||||||
// As server
|
// As server
|
||||||
internal void Close (HttpResponse response)
|
internal void Close (HttpResponse response)
|
||||||
{
|
{
|
||||||
@ -2114,8 +2120,8 @@ namespace WebSocketSharp
|
|||||||
if (message == null || message.Length == 0)
|
if (message == null || message.Length == 0)
|
||||||
return Ping ();
|
return Ping ();
|
||||||
|
|
||||||
var data = Encoding.UTF8.GetBytes (message);
|
byte[] data;
|
||||||
var msg = data.CheckIfValidControlData ("message");
|
var msg = CheckPingParameter (message, out data);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
error ("An error has occurred in sending the ping.", null);
|
error ("An error has occurred in sending the ping.", null);
|
||||||
|
Loading…
Reference in New Issue
Block a user