Remove HubProtocol minor version (#9898)
This commit is contained in:
parent
86f92cc020
commit
20d0497163
|
|
@ -72,7 +72,6 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
||||||
|
|
||||||
// Transient state to a connection
|
// Transient state to a connection
|
||||||
private ConnectionState _connectionState;
|
private ConnectionState _connectionState;
|
||||||
private int _serverProtocolMinorVersion;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the connection is closed. The connection could be closed due to an error or due to either the server or client intentionally
|
/// Occurs when the connection is closed. The connection could be closed due to an error or due to either the server or client intentionally
|
||||||
|
|
@ -953,8 +952,6 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
||||||
$"Unable to complete handshake with the server due to an error: {message.Error}");
|
$"Unable to complete handshake with the server due to an error: {message.Error}");
|
||||||
}
|
}
|
||||||
|
|
||||||
_serverProtocolMinorVersion = message.MinorVersion;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
var output = MemoryBufferWriter.Get();
|
var output = MemoryBufferWriter.Get();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HandshakeProtocol.WriteResponseMessage(new HandshakeResponseMessage(minorVersion), output);
|
HandshakeProtocol.WriteResponseMessage(HandshakeResponseMessage.Empty, output);
|
||||||
response = output.ToArray();
|
response = output.ToArray();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
{
|
{
|
||||||
public JsonHubProtocol() { }
|
public JsonHubProtocol() { }
|
||||||
public JsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions> options) { }
|
public JsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions> options) { }
|
||||||
public int MinorVersion { get { throw null; } }
|
|
||||||
public string Name { get { throw null; } }
|
public string Name { get { throw null; } }
|
||||||
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
||||||
public int Version { get { throw null; } }
|
public int Version { get { throw null; } }
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
{
|
{
|
||||||
public JsonHubProtocol() { }
|
public JsonHubProtocol() { }
|
||||||
public JsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions> options) { }
|
public JsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions> options) { }
|
||||||
public int MinorVersion { get { throw null; } }
|
|
||||||
public string Name { get { throw null; } }
|
public string Name { get { throw null; } }
|
||||||
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
||||||
public int Version { get { throw null; } }
|
public int Version { get { throw null; } }
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
|
|
||||||
private static readonly string ProtocolName = "json";
|
private static readonly string ProtocolName = "json";
|
||||||
private static readonly int ProtocolVersion = 1;
|
private static readonly int ProtocolVersion = 1;
|
||||||
private static readonly int ProtocolMinorVersion = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the serializer used to serialize invocation arguments and return values.
|
/// Gets the serializer used to serialize invocation arguments and return values.
|
||||||
|
|
@ -71,9 +70,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Version => ProtocolVersion;
|
public int Version => ProtocolVersion;
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int MinorVersion => ProtocolMinorVersion;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TransferFormat TransferFormat => TransferFormat.Text;
|
public TransferFormat TransferFormat => TransferFormat.Text;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
{
|
{
|
||||||
public MessagePackHubProtocol() { }
|
public MessagePackHubProtocol() { }
|
||||||
public MessagePackHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.MessagePackHubProtocolOptions> options) { }
|
public MessagePackHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.MessagePackHubProtocolOptions> options) { }
|
||||||
public int MinorVersion { get { throw null; } }
|
|
||||||
public string Name { get { throw null; } }
|
public string Name { get { throw null; } }
|
||||||
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
||||||
public int Version { get { throw null; } }
|
public int Version { get { throw null; } }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
|
|
||||||
private static readonly string ProtocolName = "messagepack";
|
private static readonly string ProtocolName = "messagepack";
|
||||||
private static readonly int ProtocolVersion = 1;
|
private static readonly int ProtocolVersion = 1;
|
||||||
private static readonly int ProtocolMinorVersion = 0;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Name => ProtocolName;
|
public string Name => ProtocolName;
|
||||||
|
|
@ -37,9 +36,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Version => ProtocolVersion;
|
public int Version => ProtocolVersion;
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int MinorVersion => ProtocolMinorVersion;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TransferFormat TransferFormat => TransferFormat.Binary;
|
public TransferFormat TransferFormat => TransferFormat.Binary;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
{
|
{
|
||||||
public NewtonsoftJsonHubProtocol() { }
|
public NewtonsoftJsonHubProtocol() { }
|
||||||
public NewtonsoftJsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions> options) { }
|
public NewtonsoftJsonHubProtocol(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions> options) { }
|
||||||
public int MinorVersion { get { throw null; } }
|
|
||||||
public string Name { get { throw null; } }
|
public string Name { get { throw null; } }
|
||||||
public Newtonsoft.Json.JsonSerializer PayloadSerializer { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public Newtonsoft.Json.JsonSerializer PayloadSerializer { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
public Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get { throw null; } }
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
|
|
||||||
private static readonly string ProtocolName = "json";
|
private static readonly string ProtocolName = "json";
|
||||||
private static readonly int ProtocolVersion = 1;
|
private static readonly int ProtocolVersion = 1;
|
||||||
private static readonly int ProtocolMinorVersion = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the serializer used to serialize invocation arguments and return values.
|
/// Gets the serializer used to serialize invocation arguments and return values.
|
||||||
|
|
@ -62,9 +61,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Version => ProtocolVersion;
|
public int Version => ProtocolVersion;
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int MinorVersion => ProtocolMinorVersion;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TransferFormat TransferFormat => TransferFormat.Text;
|
public TransferFormat TransferFormat => TransferFormat.Text;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,8 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
public partial class HandshakeResponseMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
public partial class HandshakeResponseMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
||||||
{
|
{
|
||||||
public static readonly Microsoft.AspNetCore.SignalR.Protocol.HandshakeResponseMessage Empty;
|
public static readonly Microsoft.AspNetCore.SignalR.Protocol.HandshakeResponseMessage Empty;
|
||||||
public HandshakeResponseMessage(int minorVersion) { }
|
|
||||||
public HandshakeResponseMessage(int? minorVersion, string error) { }
|
|
||||||
public HandshakeResponseMessage(string error) { }
|
public HandshakeResponseMessage(string error) { }
|
||||||
public string Error { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public string Error { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public int MinorVersion { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
|
||||||
}
|
}
|
||||||
public abstract partial class HubInvocationMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
public abstract partial class HubInvocationMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
||||||
{
|
{
|
||||||
|
|
@ -101,7 +98,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
}
|
}
|
||||||
public partial interface IHubProtocol
|
public partial interface IHubProtocol
|
||||||
{
|
{
|
||||||
int MinorVersion { get; }
|
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get; }
|
Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get; }
|
||||||
int Version { get; }
|
int Version { get; }
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,8 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
public partial class HandshakeResponseMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
public partial class HandshakeResponseMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
||||||
{
|
{
|
||||||
public static readonly Microsoft.AspNetCore.SignalR.Protocol.HandshakeResponseMessage Empty;
|
public static readonly Microsoft.AspNetCore.SignalR.Protocol.HandshakeResponseMessage Empty;
|
||||||
public HandshakeResponseMessage(int minorVersion) { }
|
|
||||||
public HandshakeResponseMessage(int? minorVersion, string error) { }
|
|
||||||
public HandshakeResponseMessage(string error) { }
|
public HandshakeResponseMessage(string error) { }
|
||||||
public string Error { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public string Error { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public int MinorVersion { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
|
||||||
}
|
}
|
||||||
public abstract partial class HubInvocationMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
public abstract partial class HubInvocationMessage : Microsoft.AspNetCore.SignalR.Protocol.HubMessage
|
||||||
{
|
{
|
||||||
|
|
@ -101,7 +98,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
}
|
}
|
||||||
public partial interface IHubProtocol
|
public partial interface IHubProtocol
|
||||||
{
|
{
|
||||||
int MinorVersion { get; }
|
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get; }
|
Microsoft.AspNetCore.Connections.TransferFormat TransferFormat { get; }
|
||||||
int Version { get; }
|
int Version { get; }
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
private static ReadOnlySpan<byte> ProtocolPropertyNameBytes => new byte[] { (byte)'p', (byte)'r', (byte)'o', (byte)'t', (byte)'o', (byte)'c', (byte)'o', (byte)'l' };
|
private static ReadOnlySpan<byte> ProtocolPropertyNameBytes => new byte[] { (byte)'p', (byte)'r', (byte)'o', (byte)'t', (byte)'o', (byte)'c', (byte)'o', (byte)'l' };
|
||||||
private const string ProtocolVersionPropertyName = "version";
|
private const string ProtocolVersionPropertyName = "version";
|
||||||
private static ReadOnlySpan<byte> ProtocolVersionPropertyNameBytes => new byte[] { (byte)'v', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n' };
|
private static ReadOnlySpan<byte> ProtocolVersionPropertyNameBytes => new byte[] { (byte)'v', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n' };
|
||||||
private const string MinorVersionPropertyName = "minorVersion";
|
|
||||||
private static ReadOnlySpan<byte> MinorVersionPropertyNameBytes => new byte[] { (byte)'m', (byte)'i', (byte)'n', (byte)'o', (byte)'r', (byte)'V', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n' };
|
|
||||||
private const string ErrorPropertyName = "error";
|
private const string ErrorPropertyName = "error";
|
||||||
private static ReadOnlySpan<byte> ErrorPropertyNameBytes => new byte[] { (byte)'e', (byte)'r', (byte)'r', (byte)'o', (byte)'r' };
|
private static ReadOnlySpan<byte> ErrorPropertyNameBytes => new byte[] { (byte)'e', (byte)'r', (byte)'r', (byte)'o', (byte)'r' };
|
||||||
private const string TypePropertyName = "type";
|
private const string TypePropertyName = "type";
|
||||||
|
|
@ -40,7 +38,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
var memoryBufferWriter = MemoryBufferWriter.Get();
|
var memoryBufferWriter = MemoryBufferWriter.Get();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WriteResponseMessage(new HandshakeResponseMessage(protocol.MinorVersion), memoryBufferWriter);
|
WriteResponseMessage(HandshakeResponseMessage.Empty, memoryBufferWriter);
|
||||||
result = memoryBufferWriter.ToArray();
|
result = memoryBufferWriter.ToArray();
|
||||||
_messageCache.TryAdd(protocol, result);
|
_messageCache.TryAdd(protocol, result);
|
||||||
}
|
}
|
||||||
|
|
@ -100,8 +98,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
writer.WriteString(ErrorPropertyNameBytes, responseMessage.Error);
|
writer.WriteString(ErrorPropertyNameBytes, responseMessage.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.WriteNumber(MinorVersionPropertyNameBytes, responseMessage.MinorVersion);
|
|
||||||
|
|
||||||
writer.WriteEndObject();
|
writer.WriteEndObject();
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
Debug.Assert(writer.CurrentDepth == 0);
|
Debug.Assert(writer.CurrentDepth == 0);
|
||||||
|
|
@ -133,7 +129,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
reader.CheckRead();
|
reader.CheckRead();
|
||||||
reader.EnsureObjectStart();
|
reader.EnsureObjectStart();
|
||||||
|
|
||||||
int? minorVersion = null;
|
|
||||||
string error = null;
|
string error = null;
|
||||||
|
|
||||||
while (reader.CheckRead())
|
while (reader.CheckRead())
|
||||||
|
|
@ -150,10 +145,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
{
|
{
|
||||||
error = reader.ReadAsString(ErrorPropertyName);
|
error = reader.ReadAsString(ErrorPropertyName);
|
||||||
}
|
}
|
||||||
else if (reader.TextEquals(MinorVersionPropertyNameBytes))
|
|
||||||
{
|
|
||||||
minorVersion = reader.ReadAsInt32(MinorVersionPropertyName);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reader.Skip();
|
reader.Skip();
|
||||||
|
|
@ -169,7 +160,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
responseMessage = new HandshakeResponseMessage(minorVersion, error);
|
responseMessage = new HandshakeResponseMessage(error);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SignalR.Protocol
|
namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
|
|
@ -18,34 +18,13 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Error { get; }
|
public string Error { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Highest minor protocol version that the server supports.
|
|
||||||
/// </summary>
|
|
||||||
public int MinorVersion { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HandshakeResponseMessage"/> class.
|
/// Initializes a new instance of the <see cref="HandshakeResponseMessage"/> class.
|
||||||
/// An error response does need a minor version. Since the handshake has failed, any extra data will be ignored.
|
/// An error response does need a minor version. Since the handshake has failed, any extra data will be ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="error">Error encountered by the server, indicating why the handshake has failed.</param>
|
/// <param name="error">Error encountered by the server, indicating why the handshake has failed.</param>
|
||||||
public HandshakeResponseMessage(string error) : this(null, error) { }
|
public HandshakeResponseMessage(string error)
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="HandshakeResponseMessage"/> class.
|
|
||||||
/// A reponse with a minor version indicates success, and doesn't require an error field.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="minorVersion">The highest protocol minor version that the server supports.</param>
|
|
||||||
public HandshakeResponseMessage(int minorVersion) : this(minorVersion, null) { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="HandshakeResponseMessage"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="error">Error encountered by the server, indicating why the handshake has failed.</param>
|
|
||||||
/// <param name="minorVersion">The highest protocol minor version that the server supports.</param>
|
|
||||||
public HandshakeResponseMessage(int? minorVersion, string error)
|
|
||||||
{
|
{
|
||||||
// MinorVersion defaults to 0, because old servers don't send a minor version
|
|
||||||
MinorVersion = minorVersion ?? 0;
|
|
||||||
Error = error;
|
Error = error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,6 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int Version { get; }
|
int Version { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the minor version of the protocol.
|
|
||||||
/// </summary>
|
|
||||||
int MinorVersion { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the transfer format of the protocol.
|
/// Gets the transfer format of the protocol.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
|
|
@ -59,17 +59,6 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
||||||
Assert.Equal("dummy", response.Error);
|
Assert.Equal("dummy", response.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData("{\"error\":\"\",\"minorVersion\":34}\u001e", 34)]
|
|
||||||
[InlineData("{\"error\":\"flump flump flump\",\"minorVersion\":112}\u001e", 112)]
|
|
||||||
public void ParsingResponseMessageGivesMinorVersion(string json, int version)
|
|
||||||
{
|
|
||||||
var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json));
|
|
||||||
|
|
||||||
Assert.True(HandshakeProtocol.TryParseResponseMessage(ref message, out var response));
|
|
||||||
Assert.Equal(version, response.MinorVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParsingHandshakeRequestNotCompleteReturnsFalse()
|
public void ParsingHandshakeRequestNotCompleteReturnsFalse()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
||||||
var memoryBufferWriter = MemoryBufferWriter.Get();
|
var memoryBufferWriter = MemoryBufferWriter.Get();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HandshakeProtocol.WriteResponseMessage(new HandshakeResponseMessage(1), memoryBufferWriter);
|
HandshakeProtocol.WriteResponseMessage(HandshakeResponseMessage.Empty, memoryBufferWriter);
|
||||||
result = memoryBufferWriter.ToArray();
|
result = memoryBufferWriter.ToArray();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -195,4 +195,4 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,6 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
||||||
public string Name => _name;
|
public string Name => _name;
|
||||||
|
|
||||||
public int Version => _innerProtocol.Version;
|
public int Version => _innerProtocol.Version;
|
||||||
public int MinorVersion => _innerProtocol.MinorVersion;
|
|
||||||
|
|
||||||
public TransferFormat TransferFormat => _innerProtocol.TransferFormat;
|
public TransferFormat TransferFormat => _innerProtocol.TransferFormat;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -441,7 +441,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
|
|
||||||
Log.HandshakeComplete(_logger, Protocol.Name);
|
Log.HandshakeComplete(_logger, Protocol.Name);
|
||||||
|
|
||||||
await WriteHandshakeResponseAsync(new HandshakeResponseMessage(Protocol.MinorVersion));
|
await WriteHandshakeResponseAsync(HandshakeResponseMessage.Empty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3063,7 +3063,6 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var testProtocol = new Mock<IHubProtocol>();
|
var testProtocol = new Mock<IHubProtocol>();
|
||||||
testProtocol.Setup(m => m.Name).Returns("CustomProtocol");
|
testProtocol.Setup(m => m.Name).Returns("CustomProtocol");
|
||||||
testProtocol.Setup(m => m.MinorVersion).Returns(112);
|
|
||||||
testProtocol.Setup(m => m.IsVersionSupported(It.IsAny<int>())).Returns(true);
|
testProtocol.Setup(m => m.IsVersionSupported(It.IsAny<int>())).Returns(true);
|
||||||
testProtocol.Setup(m => m.TransferFormat).Returns(TransferFormat.Binary);
|
testProtocol.Setup(m => m.TransferFormat).Returns(TransferFormat.Binary);
|
||||||
|
|
||||||
|
|
@ -3075,7 +3074,6 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
var connectionHandlerTask = await client.ConnectAsync(connectionHandler).OrTimeout();
|
var connectionHandlerTask = await client.ConnectAsync(connectionHandler).OrTimeout();
|
||||||
|
|
||||||
Assert.NotNull(client.HandshakeResponseMessage);
|
Assert.NotNull(client.HandshakeResponseMessage);
|
||||||
Assert.Equal(112, client.HandshakeResponseMessage.MinorVersion);
|
|
||||||
|
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
await connectionHandlerTask.OrTimeout();
|
await connectionHandlerTask.OrTimeout();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue