From e0a7e74d0a87442a433f7b467dd9d1b1b3c6087c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Sep 2013 17:46:57 +0900 Subject: [PATCH] Renamed WsState.cs to WebSocketState.cs --- .../Server/WebSocketServiceManager.cs | 4 +- websocket-sharp/WebSocket.cs | 87 ++++++++++--------- .../{WsState.cs => WebSocketState.cs} | 12 +-- websocket-sharp/websocket-sharp.csproj | 2 +- 4 files changed, 54 insertions(+), 51 deletions(-) rename websocket-sharp/{WsState.cs => WebSocketState.cs} (87%) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a0f7892d..cddd2932 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -587,9 +587,9 @@ namespace WebSocketSharp.Server if (_services.TryGetValue (id, out service)) { var state = service.WebSocket.ReadyState; - if (state == WsState.OPEN) + if (state == WebSocketState.OPEN) service.Stop (CloseStatusCode.ABNORMAL, String.Empty); - else if (state == WsState.CLOSING) + else if (state == WebSocketState.CLOSING) continue; else _services.Remove (id); diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bf596363..3bc4ce6c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -66,33 +66,33 @@ namespace WebSocketSharp #region Private Fields - private string _base64key; + private string _base64key; private RemoteCertificateValidationCallback - _certValidationCallback; - private bool _client; - private Action _closeContext; - private CompressionMethod _compression; - private WebSocketContext _context; - private CookieCollection _cookies; + _certValidationCallback; + private bool _client; + private Action _closeContext; + private CompressionMethod _compression; + private WebSocketContext _context; + private CookieCollection _cookies; private Func - _cookiesValidation; - private WsCredential _credentials; - private string _extensions; - private AutoResetEvent _exitReceiving; - private object _forClose; - private object _forFrame; - private object _forSend; - private volatile Logger _logger; - private string _origin; - private bool _preAuth; - private string _protocol; - private string _protocols; - private volatile WsState _readyState; - private AutoResetEvent _receivePong; - private bool _secure; - private WsStream _stream; - private TcpClient _tcpClient; - private Uri _uri; + _cookiesValidation; + private WsCredential _credentials; + private string _extensions; + private AutoResetEvent _exitReceiving; + private object _forClose; + private object _forFrame; + private object _forSend; + private volatile Logger _logger; + private string _origin; + private bool _preAuth; + private string _protocol; + private string _protocols; + private volatile WebSocketState _readyState; + private AutoResetEvent _receivePong; + private bool _secure; + private WsStream _stream; + private TcpClient _tcpClient; + private Uri _uri; #endregion @@ -110,7 +110,7 @@ namespace WebSocketSharp _origin = String.Empty; _preAuth = false; _protocol = String.Empty; - _readyState = WsState.CONNECTING; + _readyState = WebSocketState.CONNECTING; } #endregion @@ -236,7 +236,7 @@ namespace WebSocketSharp internal bool IsOpened { get { - return _readyState == WsState.OPEN || _readyState == WsState.CLOSING; + return _readyState == WebSocketState.OPEN || _readyState == WebSocketState.CLOSING; } } @@ -319,8 +319,8 @@ namespace WebSocketSharp /// public bool IsAlive { get { - return _readyState == WsState.OPEN - ? ping(new byte [] {}) + return _readyState == WebSocketState.OPEN + ? ping (new byte [] {}) : false; } } @@ -428,9 +428,10 @@ namespace WebSocketSharp /// Gets the state of the WebSocket connection. /// /// - /// One of the values. The default is . + /// One of the values. + /// The default value is . /// - public WsState ReadyState { + public WebSocketState ReadyState { get { return _readyState; } @@ -469,7 +470,7 @@ namespace WebSocketSharp } internal set { - if (_readyState == WsState.CONNECTING && !_client) + if (_readyState == WebSocketState.CONNECTING && !_client) _uri = value; } } @@ -539,7 +540,7 @@ namespace WebSocketSharp if (!closeResources ()) eventArgs.WasClean = false; - _readyState = WsState.CLOSED; + _readyState = WebSocketState.CLOSED; OnClose.Emit (this, eventArgs); } @@ -549,13 +550,13 @@ namespace WebSocketSharp CloseEventArgs args = null; lock (_forClose) { - if (_readyState == WsState.CLOSING || _readyState == WsState.CLOSED) + if (_readyState == WebSocketState.CLOSING || _readyState == WebSocketState.CLOSED) return; var state = _readyState; - _readyState = WsState.CLOSING; + _readyState = WebSocketState.CLOSING; args = new CloseEventArgs (data); - if (state == WsState.CONNECTING) + if (state == WebSocketState.CONNECTING) { if (!_client) { @@ -579,7 +580,7 @@ namespace WebSocketSharp { send (createHandshakeResponse (code)); closeResources (); - _readyState = WsState.CLOSED; + _readyState = WebSocketState.CLOSED; } private void close (ushort code, string reason) @@ -858,7 +859,7 @@ namespace WebSocketSharp private void open () { - _readyState = WsState.OPEN; + _readyState = WebSocketState.OPEN; startReceiving (); OnOpen.Emit (this, EventArgs.Empty); } @@ -1080,9 +1081,9 @@ namespace WebSocketSharp { var ready = _stream == null ? false - : _readyState == WsState.OPEN + : _readyState == WebSocketState.OPEN ? true - : _readyState == WsState.CLOSING + : _readyState == WebSocketState.CLOSING ? frame.IsClose : false; @@ -1104,7 +1105,7 @@ namespace WebSocketSharp var data = stream; var compressed = false; try { - if (_readyState != WsState.OPEN) + if (_readyState != WebSocketState.OPEN) { var msg = "The WebSocket connection isn't established or has been closed."; _logger.Error (msg); @@ -1245,7 +1246,7 @@ namespace WebSocketSharp { try { processFrame (frame); - if (_readyState == WsState.OPEN) + if (_readyState == WebSocketState.OPEN) _stream.ReadFrameAsync (completed); else _exitReceiving.Set (); @@ -1316,7 +1317,7 @@ namespace WebSocketSharp // As server internal void Close (HttpStatusCode code) { - _readyState = WsState.CLOSING; + _readyState = WebSocketState.CLOSING; close (code); } diff --git a/websocket-sharp/WsState.cs b/websocket-sharp/WebSocketState.cs similarity index 87% rename from websocket-sharp/WsState.cs rename to websocket-sharp/WebSocketState.cs index 57fabf69..a4608e16 100644 --- a/websocket-sharp/WsState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -1,6 +1,6 @@ #region License /* - * WsState.cs + * WebSocketState.cs * * The MIT License * @@ -34,21 +34,23 @@ namespace WebSocketSharp { /// Contains the values of the state of the WebSocket connection. /// /// - /// The WsState enumeration contains the values of the state of the WebSocket connection defined in + /// The WebSocketState enumeration contains the values of the state of the WebSocket connection defined in /// The WebSocket API. /// - public enum WsState : ushort + public enum WebSocketState : ushort { /// /// Equivalent to numeric value 0. Indicates that the connection has not yet been established. /// CONNECTING = 0, /// - /// Equivalent to numeric value 1. Indicates that the connection is established and communication is possible. + /// Equivalent to numeric value 1. Indicates that the connection is established and the communication + /// is possible. /// OPEN = 1, /// - /// Equivalent to numeric value 2. Indicates that the connection is going through the closing handshake, or the Close method has been invoked. + /// Equivalent to numeric value 2. Indicates that the connection is going through the closing handshake, + /// or the WebSocket.Close method has been invoked. /// CLOSING = 2, /// diff --git a/websocket-sharp/websocket-sharp.csproj b/websocket-sharp/websocket-sharp.csproj index 7d778d9a..4dee7e0c 100644 --- a/websocket-sharp/websocket-sharp.csproj +++ b/websocket-sharp/websocket-sharp.csproj @@ -63,7 +63,6 @@ - @@ -128,6 +127,7 @@ +