[Modify] Move them to the extension methods

This commit is contained in:
sta 2015-12-17 13:39:09 +09:00
parent 8359eadb8d
commit b60111fd55
2 changed files with 11 additions and 11 deletions

View File

@ -513,11 +513,21 @@ namespace WebSocketSharp
return opcode > 0x7 && opcode < 0x10;
}
internal static bool IsControl (this Opcode opcode)
{
return opcode >= Opcode.Close;
}
internal static bool IsData (this byte opcode)
{
return opcode == 0x1 || opcode == 0x2;
}
internal static bool IsData (this Opcode opcode)
{
return opcode == Opcode.Text || opcode == Opcode.Binary;
}
internal static bool IsPortNumber (this int value)
{
return value > 0 && value < 65536;

View File

@ -104,7 +104,7 @@ namespace WebSocketSharp
Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask)
{
_fin = fin;
_rsv1 = isData (opcode) && compressed ? Rsv.On : Rsv.Off;
_rsv1 = opcode.IsData () && compressed ? Rsv.On : Rsv.Off;
_rsv2 = Rsv.Off;
_rsv3 = Rsv.Off;
_opcode = opcode;
@ -377,16 +377,6 @@ namespace WebSocketSharp
return output.ToString ();
}
private static bool isControl (Opcode opcode)
{
return opcode == Opcode.Close || opcode == Opcode.Ping || opcode == Opcode.Pong;
}
private static bool isData (Opcode opcode)
{
return opcode == Opcode.Text || opcode == Opcode.Binary;
}
private static string print (WebSocketFrame frame)
{
// Payload Length