From b60111fd5578fe2b5bebd088d6f444f01ec8509c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Dec 2015 13:39:09 +0900 Subject: [PATCH] [Modify] Move them to the extension methods --- websocket-sharp/Ext.cs | 10 ++++++++++ websocket-sharp/WebSocketFrame.cs | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 42f50de6..ba9606d7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -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; diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index da969787..dc440a2a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -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