diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs
index 93a6e9b2..8bc58f1b 100644
--- a/websocket-sharp/CloseEventArgs.cs
+++ b/websocket-sharp/CloseEventArgs.cs
@@ -32,13 +32,12 @@ using System.Text;
namespace WebSocketSharp
{
///
- /// Contains the event data associated with a
- /// event.
+ /// Contains the event data associated with a event.
///
///
- /// A event occurs when the WebSocket connection
- /// has been closed. If you want to get the reason for closure, you access the
- /// or property.
+ /// A event occurs when the WebSocket connection has been closed.
+ /// If you would like to get the reason for the close, you should access the or
+ /// property.
///
public class CloseEventArgs : EventArgs
{
@@ -55,9 +54,14 @@ namespace WebSocketSharp
internal CloseEventArgs (PayloadData payload)
{
var data = payload.ApplicationData;
- _code = getCodeFrom (data);
- _reason = getReasonFrom (data);
- _clean = false;
+ var len = data.Length;
+ _code = len > 1
+ ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big)
+ : (ushort) CloseStatusCode.NoStatusCode;
+
+ _reason = len > 2
+ ? Encoding.UTF8.GetString (data.SubArray (2, len - 2))
+ : String.Empty;
}
#endregion
@@ -65,10 +69,10 @@ namespace WebSocketSharp
#region Public Properties
///
- /// Gets the status code for closure.
+ /// Gets the status code for the close.
///
///
- /// A that indicates the status code for closure if any.
+ /// A that represents the status code for the close if any.
///
public ushort Code {
get {
@@ -77,10 +81,10 @@ namespace WebSocketSharp
}
///
- /// Gets the reason for closure.
+ /// Gets the reason for the close.
///
///
- /// A that represents the reason for closure if any.
+ /// A that represents the reason for the close if any.
///
public string Reason {
get {
@@ -89,12 +93,10 @@ namespace WebSocketSharp
}
///
- /// Gets a value indicating whether the WebSocket connection has been closed
- /// cleanly.
+ /// Gets a value indicating whether the WebSocket connection has been closed cleanly.
///
///
- /// true if the WebSocket connection has been closed cleanly;
- /// otherwise, false.
+ /// true if the WebSocket connection has been closed cleanly; otherwise, false.
///
public bool WasClean {
get {
@@ -107,24 +109,5 @@ namespace WebSocketSharp
}
#endregion
-
- #region Private Methods
-
- private static ushort getCodeFrom (byte [] data)
- {
- return data.Length > 1
- ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big)
- : (ushort) CloseStatusCode.NoStatusCode;
- }
-
- private static string getReasonFrom (byte [] data)
- {
- var len = data.Length;
- return len > 2
- ? Encoding.UTF8.GetString (data.SubArray (2, len - 2))
- : String.Empty;
- }
-
- #endregion
}
}