// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.SignalR.Protocol
{
///
/// A handshake response message.
///
public class HandshakeResponseMessage : HubMessage
{
///
/// An empty response message with no error.
///
public static readonly HandshakeResponseMessage Empty = new HandshakeResponseMessage(error: null);
///
/// Gets the optional error message.
///
public string Error { get; }
///
/// Highest minor protocol version that the server supports.
///
public int MinorVersion { get; }
///
/// Initializes a new instance of the class.
/// An error response does need a minor version. Since the handshake has failed, any extra data will be ignored.
///
/// Error encountered by the server, indicating why the handshake has failed.
public HandshakeResponseMessage(string error) : this(null, error) { }
///
/// Initializes a new instance of the class.
/// A reponse with a minor version indicates success, and doesn't require an error field.
///
/// The highest protocol minor version that the server supports.
public HandshakeResponseMessage(int minorVersion) : this(minorVersion, null) { }
///
/// Initializes a new instance of the class.
///
/// Error encountered by the server, indicating why the handshake has failed.
/// The highest protocol minor version that the server supports.
public HandshakeResponseMessage(int? minorVersion, string error)
{
// MinorVersion defaults to 0, because old servers don't send a minor version
MinorVersion = minorVersion ?? 0;
Error = error;
}
}
}