Modified WebSocketState enum values to PascalCase values
This commit is contained in:
parent
e594696a38
commit
d632fc839f
@ -196,27 +196,27 @@ namespace WebSocketSharp
|
||||
|
||||
internal static string CheckIfClosable (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.CLOSING
|
||||
return state == WebSocketState.Closing
|
||||
? "While closing the WebSocket connection."
|
||||
: state == WebSocketState.CLOSED
|
||||
: state == WebSocketState.Closed
|
||||
? "The WebSocket connection has already been closed."
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfConnectable (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.OPEN || state == WebSocketState.CLOSING
|
||||
return state == WebSocketState.Open || state == WebSocketState.Closing
|
||||
? "A WebSocket connection has already been established."
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static string CheckIfOpen (this WebSocketState state)
|
||||
{
|
||||
return state == WebSocketState.CONNECTING
|
||||
return state == WebSocketState.Connecting
|
||||
? "A WebSocket connection isn't established."
|
||||
: state == WebSocketState.CLOSING
|
||||
: state == WebSocketState.Closing
|
||||
? "While closing the WebSocket connection."
|
||||
: state == WebSocketState.CLOSED
|
||||
: state == WebSocketState.Closed
|
||||
? "The WebSocket connection has already been closed."
|
||||
: null;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
set {
|
||||
if (State == WebSocketState.CONNECTING &&
|
||||
if (State == WebSocketState.Connecting &&
|
||||
value != null &&
|
||||
value.Length > 0 &&
|
||||
value.IsToken ())
|
||||
@ -184,7 +184,7 @@ namespace WebSocketSharp.Server
|
||||
get {
|
||||
return _websocket != null
|
||||
? _websocket.ReadyState
|
||||
: WebSocketState.CONNECTING;
|
||||
: WebSocketState.Connecting;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,9 +811,9 @@ namespace WebSocketSharp.Server
|
||||
IWebSocketSession session;
|
||||
if (_sessions.TryGetValue (id, out session)) {
|
||||
var state = session.State;
|
||||
if (state == WebSocketState.OPEN)
|
||||
if (state == WebSocketState.Open)
|
||||
session.Context.WebSocket.Close (CloseStatusCode.Abnormal);
|
||||
else if (state == WebSocketState.CLOSING)
|
||||
else if (state == WebSocketState.Closing)
|
||||
continue;
|
||||
else
|
||||
_sessions.Remove (id);
|
||||
|
@ -204,7 +204,7 @@ namespace WebSocketSharp
|
||||
|
||||
internal bool IsConnected {
|
||||
get {
|
||||
return _readyState == WebSocketState.OPEN || _readyState == WebSocketState.CLOSING;
|
||||
return _readyState == WebSocketState.Open || _readyState == WebSocketState.Closing;
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ namespace WebSocketSharp
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// One of the <see cref="WebSocketState"/> enum values, indicates the state of the WebSocket
|
||||
/// connection. The default value is <see cref="WebSocketState.CONNECTING"/>.
|
||||
/// connection. The default value is <see cref="WebSocketState.Connecting"/>.
|
||||
/// </value>
|
||||
public WebSocketState ReadyState {
|
||||
get {
|
||||
@ -522,7 +522,7 @@ namespace WebSocketSharp
|
||||
}
|
||||
|
||||
error (msg ?? code.GetMessage ());
|
||||
if (_readyState == WebSocketState.CONNECTING && !_client)
|
||||
if (_readyState == WebSocketState.Connecting && !_client)
|
||||
Close (HttpStatusCode.BadRequest);
|
||||
else
|
||||
close (code, reason ?? code.GetMessage (), false);
|
||||
@ -668,7 +668,7 @@ namespace WebSocketSharp
|
||||
|
||||
private string checkIfCanConnect ()
|
||||
{
|
||||
return !_client && _readyState == WebSocketState.CLOSED
|
||||
return !_client && _readyState == WebSocketState.Closed
|
||||
? "Connect isn't available to reconnect as a server."
|
||||
: _readyState.CheckIfConnectable ();
|
||||
}
|
||||
@ -718,12 +718,12 @@ namespace WebSocketSharp
|
||||
private void close (PayloadData payload, bool send, bool wait)
|
||||
{
|
||||
lock (_forConn) {
|
||||
if (_readyState == WebSocketState.CLOSING || _readyState == WebSocketState.CLOSED) {
|
||||
if (_readyState == WebSocketState.Closing || _readyState == WebSocketState.Closed) {
|
||||
_logger.Info ("Closing the WebSocket connection has already been done.");
|
||||
return;
|
||||
}
|
||||
|
||||
_readyState = WebSocketState.CLOSING;
|
||||
_readyState = WebSocketState.Closing;
|
||||
}
|
||||
|
||||
_logger.Trace ("Start closing handshake.");
|
||||
@ -742,7 +742,7 @@ namespace WebSocketSharp
|
||||
|
||||
_logger.Trace ("End closing handshake.");
|
||||
|
||||
_readyState = WebSocketState.CLOSED;
|
||||
_readyState = WebSocketState.Closed;
|
||||
try {
|
||||
OnClose.Emit (this, args);
|
||||
}
|
||||
@ -871,7 +871,7 @@ namespace WebSocketSharp
|
||||
|
||||
try {
|
||||
if (_client ? doHandshake () : acceptHandshake ()) {
|
||||
_readyState = WebSocketState.OPEN;
|
||||
_readyState = WebSocketState.Open;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1001,14 +1001,14 @@ namespace WebSocketSharp
|
||||
_cookies = new CookieCollection ();
|
||||
_forConn = new object ();
|
||||
_forSend = new object ();
|
||||
_readyState = WebSocketState.CONNECTING;
|
||||
_readyState = WebSocketState.Connecting;
|
||||
}
|
||||
|
||||
private void open ()
|
||||
{
|
||||
try {
|
||||
OnOpen.Emit (this, EventArgs.Empty);
|
||||
if (_readyState == WebSocketState.OPEN)
|
||||
if (_readyState == WebSocketState.Open)
|
||||
startReceiving ();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@ -1028,7 +1028,7 @@ namespace WebSocketSharp
|
||||
private bool send (byte [] frame)
|
||||
{
|
||||
lock (_forConn) {
|
||||
if (_readyState != WebSocketState.OPEN) {
|
||||
if (_readyState != WebSocketState.Open) {
|
||||
_logger.Warn ("Sending has been interrupted.");
|
||||
return false;
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ namespace WebSocketSharp
|
||||
private bool send (WsFrame frame)
|
||||
{
|
||||
lock (_forConn) {
|
||||
if (_readyState != WebSocketState.OPEN) {
|
||||
if (_readyState != WebSocketState.Open) {
|
||||
_logger.Warn ("Sending has been interrupted.");
|
||||
return false;
|
||||
}
|
||||
@ -1355,12 +1355,12 @@ namespace WebSocketSharp
|
||||
// As server
|
||||
internal void Close (HandshakeResponse response)
|
||||
{
|
||||
_readyState = WebSocketState.CLOSING;
|
||||
_readyState = WebSocketState.Closing;
|
||||
|
||||
send (response);
|
||||
closeServerResources ();
|
||||
|
||||
_readyState = WebSocketState.CLOSED;
|
||||
_readyState = WebSocketState.Closed;
|
||||
}
|
||||
|
||||
// As server
|
||||
@ -1373,17 +1373,17 @@ namespace WebSocketSharp
|
||||
internal void Close (CloseEventArgs args, byte [] frame, int timeout)
|
||||
{
|
||||
lock (_forConn) {
|
||||
if (_readyState == WebSocketState.CLOSING || _readyState == WebSocketState.CLOSED) {
|
||||
if (_readyState == WebSocketState.Closing || _readyState == WebSocketState.Closed) {
|
||||
_logger.Info ("Closing the WebSocket connection has already been done.");
|
||||
return;
|
||||
}
|
||||
|
||||
_readyState = WebSocketState.CLOSING;
|
||||
_readyState = WebSocketState.Closing;
|
||||
}
|
||||
|
||||
args.WasClean = closeHandshake (frame, timeout, closeServerResources);
|
||||
|
||||
_readyState = WebSocketState.CLOSED;
|
||||
_readyState = WebSocketState.Closed;
|
||||
try {
|
||||
OnClose.Emit (this, args);
|
||||
}
|
||||
@ -1397,7 +1397,7 @@ namespace WebSocketSharp
|
||||
{
|
||||
try {
|
||||
if (acceptHandshake ()) {
|
||||
_readyState = WebSocketState.OPEN;
|
||||
_readyState = WebSocketState.Open;
|
||||
open ();
|
||||
}
|
||||
}
|
||||
@ -1436,7 +1436,7 @@ namespace WebSocketSharp
|
||||
{
|
||||
lock (_forSend) {
|
||||
lock (_forConn) {
|
||||
if (_readyState != WebSocketState.OPEN)
|
||||
if (_readyState != WebSocketState.Open)
|
||||
return;
|
||||
|
||||
try {
|
||||
@ -1476,7 +1476,7 @@ namespace WebSocketSharp
|
||||
else
|
||||
cached.Position = 0;
|
||||
|
||||
if (_readyState == WebSocketState.OPEN)
|
||||
if (_readyState == WebSocketState.Open)
|
||||
sendFragmented (opcode, cached, Mask.Unmask, _compression != CompressionMethod.None);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@ -1503,7 +1503,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN;
|
||||
var send = _readyState == WebSocketState.Open;
|
||||
close (new PayloadData (), send, send);
|
||||
}
|
||||
|
||||
@ -1565,7 +1565,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN && !code.IsReserved ();
|
||||
var send = _readyState == WebSocketState.Open && !code.IsReserved ();
|
||||
close (new PayloadData (data), send, send);
|
||||
}
|
||||
|
||||
@ -1597,7 +1597,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN && !code.IsReserved ();
|
||||
var send = _readyState == WebSocketState.Open && !code.IsReserved ();
|
||||
close (new PayloadData (data), send, send);
|
||||
}
|
||||
|
||||
@ -1617,7 +1617,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN;
|
||||
var send = _readyState == WebSocketState.Open;
|
||||
closeAsync (new PayloadData (), send, send);
|
||||
}
|
||||
|
||||
@ -1692,7 +1692,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN && !code.IsReserved ();
|
||||
var send = _readyState == WebSocketState.Open && !code.IsReserved ();
|
||||
closeAsync (new PayloadData (data), send, send);
|
||||
}
|
||||
|
||||
@ -1730,7 +1730,7 @@ namespace WebSocketSharp
|
||||
return;
|
||||
}
|
||||
|
||||
var send = _readyState == WebSocketState.OPEN && !code.IsReserved ();
|
||||
var send = _readyState == WebSocketState.Open && !code.IsReserved ();
|
||||
closeAsync (new PayloadData (data), send, send);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010-2013 sta.blockhead
|
||||
* Copyright (c) 2010-2014 sta.blockhead
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -28,34 +28,38 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace WebSocketSharp {
|
||||
|
||||
namespace WebSocketSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the values of the state of the WebSocket connection.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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>.
|
||||
/// The state of the WebSocket connection is defined in
|
||||
/// <see href="http://www.w3.org/TR/websockets/#dom-websocket-readystate">The WebSocket
|
||||
/// API</see>.
|
||||
/// </remarks>
|
||||
public enum WebSocketState : ushort
|
||||
{
|
||||
/// <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>
|
||||
CONNECTING = 0,
|
||||
Connecting = 0,
|
||||
/// <summary>
|
||||
/// Equivalent to numeric value 1. Indicates that the connection is established and the communication
|
||||
/// is possible.
|
||||
/// Equivalent to numeric value 1.
|
||||
/// Indicates that the connection is established and the communication is possible.
|
||||
/// </summary>
|
||||
OPEN = 1,
|
||||
Open = 1,
|
||||
/// <summary>
|
||||
/// Equivalent to numeric value 2. Indicates that the connection is going through the closing handshake,
|
||||
/// or the WebSocket.Close method has been invoked.
|
||||
/// Equivalent to numeric value 2.
|
||||
/// Indicates that the connection is going through the closing handshake or
|
||||
/// the <c>WebSocket.Close</c> method has been invoked.
|
||||
/// </summary>
|
||||
CLOSING = 2,
|
||||
Closing = 2,
|
||||
/// <summary>
|
||||
/// Equivalent to numeric value 3. Indicates that the connection has been closed or could not be opened.
|
||||
/// Equivalent to numeric value 3.
|
||||
/// Indicates that the connection has been closed or couldn't be opened.
|
||||
/// </summary>
|
||||
CLOSED = 3
|
||||
Closed = 3
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user