Remove MSG from SignalR (#2006)

This commit is contained in:
Andrew Stanton-Nurse 2018-04-13 17:08:02 -07:00 committed by GitHub
parent c7f7f36210
commit 1fbb940b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 27 deletions

View File

@ -77,7 +77,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
[Params(0, 1, 10, 100)]
public int ArgumentCount;
[Params("json", "msgpack")]
[Params("json", "messagepack")]
public string Protocol;
[GlobalCleanup]

View File

@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
{
yield return ((i % 2) == 0)
? new WrappedHubProtocol($"json_{i}", new JsonHubProtocol())
: new WrappedHubProtocol($"msgpack_{i}", new MessagePackHubProtocol());
: new WrappedHubProtocol($"messagepack_{i}", new MessagePackHubProtocol());
}
}

View File

@ -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.
import { DefaultHttpClient, HttpClient, HttpRequest, HttpResponse, HttpTransportType, HubConnection, IHubConnectionOptions, JsonHubProtocol, LogLevel } from "@aspnet/signalr";
@ -396,7 +396,7 @@ describe("hubConnection", () => {
})
.then((value) => {
if (protocol.name === "messagepack") {
// msgpack creates a Buffer for byte arrays and jasmine fails to compare a Buffer
// msgpack5 creates a Buffer for byte arrays and jasmine fails to compare a Buffer
// and a Uint8Array even though Buffer instances are also Uint8Array instances
value.ByteArray = new Uint8Array(value.ByteArray);
}
@ -440,7 +440,7 @@ describe("hubConnection", () => {
})
.then((value) => {
if (protocol.name === "messagepack") {
// msgpack creates a Buffer for byte arrays and jasmine fails to compare a Buffer
// msgpack5 creates a Buffer for byte arrays and jasmine fails to compare a Buffer
// and a Uint8Array even though Buffer instances are also Uint8Array instances
value.ByteArray = new Uint8Array(value.ByteArray);
}
@ -632,7 +632,7 @@ describe("hubConnection", () => {
});
}
it("skips Server-Sent Events when negotiating for MsgPack protocol", async (done) => {
it("skips Server-Sent Events when negotiating for MessagePack protocol", async (done) => {
const hubConnection = new HubConnection(TESTHUB_NOWEBSOCKETS_ENDPOINT_URL, {
...commonOptions,
protocol: new MessagePackHubProtocol(),

View File

@ -1,31 +1,33 @@
// 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.
using System;
using System.Linq;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
{
public static class MsgPackProtocolDependencyInjectionExtensions
public static class MessagePackProtocolDependencyInjectionExtensions
{
/// <summary>
/// Enables the MsgPack protocol for SignalR.
/// Enables the MessagePack protocol for SignalR.
/// </summary>
/// <remarks>
/// This has no effect if the MsgPack protocol has already been enabled.
/// This has no effect if the MessagePack protocol has already been enabled.
/// </remarks>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add MsgPack protocol support to.</param>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add MessagePack protocol support to.</param>
/// <returns>The value of <paramref name="builder"/></returns>
public static TBuilder AddMessagePackProtocol<TBuilder>(this TBuilder builder) where TBuilder : ISignalRBuilder
=> AddMessagePackProtocol(builder, _ => { });
/// <summary>
/// Enables the MsgPack protocol for SignalR and allows options for the MsgPack protocol to be configured.
/// Enables the MessagePack protocol for SignalR and allows options for the MessagePack protocol to be configured.
/// </summary>
/// <remarks>
/// Any options configured here will be applied, even if the MsgPack protocol has already been registered with the server.
/// Any options configured here will be applied, even if the MessagePack protocol has already been registered.
/// </remarks>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add MsgPack protocol support to.</param>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add MessagePack protocol support to.</param>
/// <param name="configure">A delegate that can be used to configure the <see cref="MessagePackHubProtocolOptions"/></param>
/// <returns>The value of <paramref name="builder"/></returns>
public static TBuilder AddMessagePackProtocol<TBuilder>(this TBuilder builder, Action<MessagePackHubProtocolOptions> configure) where TBuilder : ISignalRBuilder

View File

@ -5,7 +5,7 @@ using MessagePack;
namespace Microsoft.AspNetCore.SignalR.Redis.Internal
{
internal static class MsgPackUtil
internal static class MessagePackUtil
{
public static int ReadArrayHeader(ref ReadOnlyMemory<byte> data)
{

View File

@ -127,13 +127,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
// Read excluded Ids
IReadOnlyList<string> excludedIds = null;
var idCount = MsgPackUtil.ReadArrayHeader(ref data);
var idCount = MessagePackUtil.ReadArrayHeader(ref data);
if (idCount > 0)
{
var ids = new string[idCount];
for (var i = 0; i < idCount; i++)
{
ids[i] = MsgPackUtil.ReadString(ref data);
ids[i] = MessagePackUtil.ReadString(ref data);
}
excludedIds = ids;
@ -149,11 +149,11 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
// See WriteGroupCommand for format.
ValidateArraySize(ref data, 5, "GroupCommand");
var id = MsgPackUtil.ReadInt32(ref data);
var serverName = MsgPackUtil.ReadString(ref data);
var action = (GroupAction)MsgPackUtil.ReadByte(ref data);
var groupName = MsgPackUtil.ReadString(ref data);
var connectionId = MsgPackUtil.ReadString(ref data);
var id = MessagePackUtil.ReadInt32(ref data);
var serverName = MessagePackUtil.ReadString(ref data);
var action = (GroupAction)MessagePackUtil.ReadByte(ref data);
var groupName = MessagePackUtil.ReadString(ref data);
var connectionId = MessagePackUtil.ReadString(ref data);
return new RedisGroupCommand(id, serverName, action, groupName, connectionId);
}
@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
{
// See WriteAck for format
ValidateArraySize(ref data, 1, "Ack");
return MsgPackUtil.ReadInt32(ref data);
return MessagePackUtil.ReadInt32(ref data);
}
private void WriteSerializedHubMessage(Stream stream, SerializedHubMessage message)
@ -185,12 +185,12 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
public static SerializedHubMessage ReadSerializedHubMessage(ref ReadOnlyMemory<byte> data)
{
var count = MsgPackUtil.ReadMapHeader(ref data);
var count = MessagePackUtil.ReadMapHeader(ref data);
var serializations = new SerializedMessage[count];
for (var i = 0; i < count; i++)
{
var protocol = MsgPackUtil.ReadString(ref data);
var serialized = MsgPackUtil.ReadBytes(ref data);
var protocol = MessagePackUtil.ReadString(ref data);
var serialized = MessagePackUtil.ReadBytes(ref data);
serializations[i] = new SerializedMessage(protocol, serialized);
}
@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
private static void ValidateArraySize(ref ReadOnlyMemory<byte> data, int expectedLength, string messageType)
{
var length = MsgPackUtil.ReadArrayHeader(ref data);
var length = MessagePackUtil.ReadArrayHeader(ref data);
if (length < expectedLength)
{