Are you an LLM? You can read better optimized documentation at /roadmap/messagepack.md for this page in Markdown format
MessagePack Protocol
Status: Fully implemented across all clients (.NET, TypeScript, Swift).
Overview
SignalARRR supports MessagePack alongside JSON. Both protocols run simultaneously — different clients can use different protocols on the same hub.
Architecture:
IProtocolSerializerabstraction inCocoar.SignalARRR.Common.SerializationJsonProtocolSerializerhandles bothJsonElement(JSON) and plain .NET objects (MessagePack) via its fallback- All
JsonElement/JsonSerializerdirect usage removed fromMessageHandlerandServerStreamManager
Server Setup
csharp
builder.Services.AddSignalR()
.AddMessagePackProtocol(); // Add this line — that's it
builder.Services.AddSignalARRR(options => options
.AddServerMethodsFrom(typeof(Program).Assembly));.NET Client
bash
dotnet add package Microsoft.AspNetCore.SignalR.Protocols.MessagePackcsharp
var connection = HARRRConnection.Create(builder => {
builder.WithUrl("https://server/hub");
builder.AddMessagePackProtocol();
});TypeScript Client
bash
npm install @microsoft/signalr-protocol-msgpackts
import { MessagePackHubProtocol } from '@microsoft/signalr-protocol-msgpack';
const connection = HARRRConnection.create(builder => {
builder.withUrl('https://server/hub');
builder.withHubProtocol(new MessagePackHubProtocol());
});Swift Client
No external dependencies — MessagePack is implemented natively in the Swift client.
swift
let connection = await HARRRConnection.create(
url: "https://server/hub",
hubProtocol: .messagepack
)Or using SignalRWebSocketClient directly:
swift
let client = SignalRWebSocketClient(
url: "https://server/hub",
hubProtocol: .messagepack
)Tests
- 5 .NET MessagePack integration tests (invoke, send, echo, guid, multi-param)
- 5 TypeScript MessagePack integration tests (same scenarios)
- 5 Swift MessagePack integration tests (invoke, guid, send, echo, streaming with multiple int params)
- All running alongside JSON tests on the same server instance