Renamed WsState.cs to WebSocketState.cs

This commit is contained in:
sta 2013-09-05 17:46:57 +09:00
parent d98aad51e6
commit e0a7e74d0a
4 changed files with 54 additions and 51 deletions

View File

@ -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);

View File

@ -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<CookieCollection, CookieCollection, bool>
_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
/// </value>
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.
/// </summary>
/// <value>
/// One of the <see cref="WebSocketSharp.WsState"/> values. The default is <see cref="WsState.CONNECTING"/>.
/// One of the <see cref="WebSocketState"/> values.
/// The default value is <see cref="WebSocketState.CONNECTING"/>.
/// </value>
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);
}

View File

@ -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.
/// </summary>
/// <remarks>
/// The <b>WsState</b> 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
/// <a href="http://www.w3.org/TR/websockets/#dom-websocket-readystate">The WebSocket API</a>.
/// </remarks>
public enum WsState : ushort
public enum WebSocketState : ushort
{
/// <summary>
/// Equivalent to numeric value 0. Indicates that the connection has not yet been established.
/// </summary>
CONNECTING = 0,
/// <summary>
/// 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.
/// </summary>
OPEN = 1,
/// <summary>
/// Equivalent to numeric value 2. Indicates that the connection is going through the closing handshake, or the <b>Close</b> 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.
/// </summary>
CLOSING = 2,
/// <summary>

View File

@ -63,7 +63,6 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Ext.cs" />
<Compile Include="WsState.cs" />
<Compile Include="MessageEventArgs.cs" />
<Compile Include="CloseEventArgs.cs" />
<Compile Include="ByteOrder.cs" />
@ -128,6 +127,7 @@
<Compile Include="HandshakeResponse.cs" />
<Compile Include="Server\WebSocketServiceHostManager.cs" />
<Compile Include="Server\IWebSocketServiceHost.cs" />
<Compile Include="WebSocketState.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>