Renamed WsState.cs to WebSocketState.cs
This commit is contained in:
parent
d98aad51e6
commit
e0a7e74d0a
@ -587,9 +587,9 @@ namespace WebSocketSharp.Server
|
|||||||
if (_services.TryGetValue (id, out service))
|
if (_services.TryGetValue (id, out service))
|
||||||
{
|
{
|
||||||
var state = service.WebSocket.ReadyState;
|
var state = service.WebSocket.ReadyState;
|
||||||
if (state == WsState.OPEN)
|
if (state == WebSocketState.OPEN)
|
||||||
service.Stop (CloseStatusCode.ABNORMAL, String.Empty);
|
service.Stop (CloseStatusCode.ABNORMAL, String.Empty);
|
||||||
else if (state == WsState.CLOSING)
|
else if (state == WebSocketState.CLOSING)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
_services.Remove (id);
|
_services.Remove (id);
|
||||||
|
@ -87,7 +87,7 @@ namespace WebSocketSharp
|
|||||||
private bool _preAuth;
|
private bool _preAuth;
|
||||||
private string _protocol;
|
private string _protocol;
|
||||||
private string _protocols;
|
private string _protocols;
|
||||||
private volatile WsState _readyState;
|
private volatile WebSocketState _readyState;
|
||||||
private AutoResetEvent _receivePong;
|
private AutoResetEvent _receivePong;
|
||||||
private bool _secure;
|
private bool _secure;
|
||||||
private WsStream _stream;
|
private WsStream _stream;
|
||||||
@ -110,7 +110,7 @@ namespace WebSocketSharp
|
|||||||
_origin = String.Empty;
|
_origin = String.Empty;
|
||||||
_preAuth = false;
|
_preAuth = false;
|
||||||
_protocol = String.Empty;
|
_protocol = String.Empty;
|
||||||
_readyState = WsState.CONNECTING;
|
_readyState = WebSocketState.CONNECTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -236,7 +236,7 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
internal bool IsOpened {
|
internal bool IsOpened {
|
||||||
get {
|
get {
|
||||||
return _readyState == WsState.OPEN || _readyState == WsState.CLOSING;
|
return _readyState == WebSocketState.OPEN || _readyState == WebSocketState.CLOSING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ namespace WebSocketSharp
|
|||||||
/// </value>
|
/// </value>
|
||||||
public bool IsAlive {
|
public bool IsAlive {
|
||||||
get {
|
get {
|
||||||
return _readyState == WsState.OPEN
|
return _readyState == WebSocketState.OPEN
|
||||||
? ping (new byte [] {})
|
? ping (new byte [] {})
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
@ -428,9 +428,10 @@ namespace WebSocketSharp
|
|||||||
/// Gets the state of the WebSocket connection.
|
/// Gets the state of the WebSocket connection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <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>
|
/// </value>
|
||||||
public WsState ReadyState {
|
public WebSocketState ReadyState {
|
||||||
get {
|
get {
|
||||||
return _readyState;
|
return _readyState;
|
||||||
}
|
}
|
||||||
@ -469,7 +470,7 @@ namespace WebSocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal set {
|
internal set {
|
||||||
if (_readyState == WsState.CONNECTING && !_client)
|
if (_readyState == WebSocketState.CONNECTING && !_client)
|
||||||
_uri = value;
|
_uri = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,7 +540,7 @@ namespace WebSocketSharp
|
|||||||
if (!closeResources ())
|
if (!closeResources ())
|
||||||
eventArgs.WasClean = false;
|
eventArgs.WasClean = false;
|
||||||
|
|
||||||
_readyState = WsState.CLOSED;
|
_readyState = WebSocketState.CLOSED;
|
||||||
OnClose.Emit (this, eventArgs);
|
OnClose.Emit (this, eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,13 +550,13 @@ namespace WebSocketSharp
|
|||||||
CloseEventArgs args = null;
|
CloseEventArgs args = null;
|
||||||
lock (_forClose)
|
lock (_forClose)
|
||||||
{
|
{
|
||||||
if (_readyState == WsState.CLOSING || _readyState == WsState.CLOSED)
|
if (_readyState == WebSocketState.CLOSING || _readyState == WebSocketState.CLOSED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var state = _readyState;
|
var state = _readyState;
|
||||||
_readyState = WsState.CLOSING;
|
_readyState = WebSocketState.CLOSING;
|
||||||
args = new CloseEventArgs (data);
|
args = new CloseEventArgs (data);
|
||||||
if (state == WsState.CONNECTING)
|
if (state == WebSocketState.CONNECTING)
|
||||||
{
|
{
|
||||||
if (!_client)
|
if (!_client)
|
||||||
{
|
{
|
||||||
@ -579,7 +580,7 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
send (createHandshakeResponse (code));
|
send (createHandshakeResponse (code));
|
||||||
closeResources ();
|
closeResources ();
|
||||||
_readyState = WsState.CLOSED;
|
_readyState = WebSocketState.CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close (ushort code, string reason)
|
private void close (ushort code, string reason)
|
||||||
@ -858,7 +859,7 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
private void open ()
|
private void open ()
|
||||||
{
|
{
|
||||||
_readyState = WsState.OPEN;
|
_readyState = WebSocketState.OPEN;
|
||||||
startReceiving ();
|
startReceiving ();
|
||||||
OnOpen.Emit (this, EventArgs.Empty);
|
OnOpen.Emit (this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
@ -1080,9 +1081,9 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
var ready = _stream == null
|
var ready = _stream == null
|
||||||
? false
|
? false
|
||||||
: _readyState == WsState.OPEN
|
: _readyState == WebSocketState.OPEN
|
||||||
? true
|
? true
|
||||||
: _readyState == WsState.CLOSING
|
: _readyState == WebSocketState.CLOSING
|
||||||
? frame.IsClose
|
? frame.IsClose
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
@ -1104,7 +1105,7 @@ namespace WebSocketSharp
|
|||||||
var data = stream;
|
var data = stream;
|
||||||
var compressed = false;
|
var compressed = false;
|
||||||
try {
|
try {
|
||||||
if (_readyState != WsState.OPEN)
|
if (_readyState != WebSocketState.OPEN)
|
||||||
{
|
{
|
||||||
var msg = "The WebSocket connection isn't established or has been closed.";
|
var msg = "The WebSocket connection isn't established or has been closed.";
|
||||||
_logger.Error (msg);
|
_logger.Error (msg);
|
||||||
@ -1245,7 +1246,7 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
processFrame (frame);
|
processFrame (frame);
|
||||||
if (_readyState == WsState.OPEN)
|
if (_readyState == WebSocketState.OPEN)
|
||||||
_stream.ReadFrameAsync (completed);
|
_stream.ReadFrameAsync (completed);
|
||||||
else
|
else
|
||||||
_exitReceiving.Set ();
|
_exitReceiving.Set ();
|
||||||
@ -1316,7 +1317,7 @@ namespace WebSocketSharp
|
|||||||
// As server
|
// As server
|
||||||
internal void Close (HttpStatusCode code)
|
internal void Close (HttpStatusCode code)
|
||||||
{
|
{
|
||||||
_readyState = WsState.CLOSING;
|
_readyState = WebSocketState.CLOSING;
|
||||||
close (code);
|
close (code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#region License
|
#region License
|
||||||
/*
|
/*
|
||||||
* WsState.cs
|
* WebSocketState.cs
|
||||||
*
|
*
|
||||||
* The MIT License
|
* The MIT License
|
||||||
*
|
*
|
||||||
@ -34,21 +34,23 @@ namespace WebSocketSharp {
|
|||||||
/// Contains the values of the state of the WebSocket connection.
|
/// Contains the values of the state of the WebSocket connection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <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>.
|
/// <a href="http://www.w3.org/TR/websockets/#dom-websocket-readystate">The WebSocket API</a>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public enum WsState : ushort
|
public enum WebSocketState : ushort
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Equivalent to numeric value 0. Indicates that the connection has not yet been established.
|
/// Equivalent to numeric value 0. Indicates that the connection has not yet been established.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CONNECTING = 0,
|
CONNECTING = 0,
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
OPEN = 1,
|
OPEN = 1,
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
CLOSING = 2,
|
CLOSING = 2,
|
||||||
/// <summary>
|
/// <summary>
|
@ -63,7 +63,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AssemblyInfo.cs" />
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
<Compile Include="Ext.cs" />
|
<Compile Include="Ext.cs" />
|
||||||
<Compile Include="WsState.cs" />
|
|
||||||
<Compile Include="MessageEventArgs.cs" />
|
<Compile Include="MessageEventArgs.cs" />
|
||||||
<Compile Include="CloseEventArgs.cs" />
|
<Compile Include="CloseEventArgs.cs" />
|
||||||
<Compile Include="ByteOrder.cs" />
|
<Compile Include="ByteOrder.cs" />
|
||||||
@ -128,6 +127,7 @@
|
|||||||
<Compile Include="HandshakeResponse.cs" />
|
<Compile Include="HandshakeResponse.cs" />
|
||||||
<Compile Include="Server\WebSocketServiceHostManager.cs" />
|
<Compile Include="Server\WebSocketServiceHostManager.cs" />
|
||||||
<Compile Include="Server\IWebSocketServiceHost.cs" />
|
<Compile Include="Server\IWebSocketServiceHost.cs" />
|
||||||
|
<Compile Include="WebSocketState.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user