Modified the WebSocketServer class, fix for 'No Status Code' for the stop
This commit is contained in:
		@@ -834,20 +834,15 @@ namespace WebSocketSharp.Server
 | 
			
		||||
    /// and <see cref="string"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="code">
 | 
			
		||||
    /// A <see cref="ushort"/> that represents the status code indicating the reason for stop.
 | 
			
		||||
    /// A <see cref="ushort"/> that represents the status code indicating the reason for the stop.
 | 
			
		||||
    /// </param>
 | 
			
		||||
    /// <param name="reason">
 | 
			
		||||
    /// A <see cref="string"/> that represents the reason for stop.
 | 
			
		||||
    /// A <see cref="string"/> that represents the reason for the stop.
 | 
			
		||||
    /// </param>
 | 
			
		||||
    public void Stop (ushort code, string reason)
 | 
			
		||||
    {
 | 
			
		||||
      CloseEventArgs e = null;
 | 
			
		||||
      lock (_sync) {
 | 
			
		||||
        var msg =
 | 
			
		||||
          _state.CheckIfStart () ??
 | 
			
		||||
          code.CheckIfValidCloseStatusCode () ??
 | 
			
		||||
          (e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
 | 
			
		||||
 | 
			
		||||
        var msg = _state.CheckIfStart () ?? code.CheckIfValidCloseParameters (reason);
 | 
			
		||||
        if (msg != null) {
 | 
			
		||||
          _logger.Error (msg);
 | 
			
		||||
          return;
 | 
			
		||||
@@ -857,9 +852,13 @@ namespace WebSocketSharp.Server
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      stopReceiving (5000);
 | 
			
		||||
 | 
			
		||||
      var send = !code.IsReserved ();
 | 
			
		||||
      _services.Stop (e, send, send);
 | 
			
		||||
      if (code.IsNoStatusCode ()) {
 | 
			
		||||
        _services.Stop (new CloseEventArgs (), true, true);
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        var send = !code.IsReserved ();
 | 
			
		||||
        _services.Stop (new CloseEventArgs (code, reason), send, send);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      _state = ServerState.Stop;
 | 
			
		||||
    }
 | 
			
		||||
@@ -870,19 +869,15 @@ namespace WebSocketSharp.Server
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="code">
 | 
			
		||||
    /// One of the <see cref="CloseStatusCode"/> enum values, represents the status code
 | 
			
		||||
    /// indicating the reason for stop.
 | 
			
		||||
    /// indicating the reason for the stop.
 | 
			
		||||
    /// </param>
 | 
			
		||||
    /// <param name="reason">
 | 
			
		||||
    /// A <see cref="string"/> that represents the reason for stop.
 | 
			
		||||
    /// A <see cref="string"/> that represents the reason for the stop.
 | 
			
		||||
    /// </param>
 | 
			
		||||
    public void Stop (CloseStatusCode code, string reason)
 | 
			
		||||
    {
 | 
			
		||||
      CloseEventArgs e = null;
 | 
			
		||||
      lock (_sync) {
 | 
			
		||||
        var msg =
 | 
			
		||||
          _state.CheckIfStart () ??
 | 
			
		||||
          (e = new CloseEventArgs (code, reason)).RawData.CheckIfValidControlData ("reason");
 | 
			
		||||
 | 
			
		||||
        var msg = _state.CheckIfStart () ?? code.CheckIfValidCloseParameters (reason);
 | 
			
		||||
        if (msg != null) {
 | 
			
		||||
          _logger.Error (msg);
 | 
			
		||||
          return;
 | 
			
		||||
@@ -892,9 +887,13 @@ namespace WebSocketSharp.Server
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      stopReceiving (5000);
 | 
			
		||||
 | 
			
		||||
      var send = !code.IsReserved ();
 | 
			
		||||
      _services.Stop (e, send, send);
 | 
			
		||||
      if (code.IsNoStatusCode ()) {
 | 
			
		||||
        _services.Stop (new CloseEventArgs (), true, true);
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        var send = !code.IsReserved ();
 | 
			
		||||
        _services.Stop (new CloseEventArgs (code, reason), send, send);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      _state = ServerState.Stop;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user