Out of the box, SignalR sends messages in plaintext JSON, but there is an alternative, which is MessagePack. It is a compressed format that can provide a better performance, especially for bigger payloads.
As mentioned earlier, we will need to install the @aspnet/signalr-protocol-msgpack npm package and the Microsoft.AspNetCore.SignalR.Protocols.MessagePack NuGet package.
An example, where we can specify the MessagePack protocol, would be as follows:
var connection = new signalR.HubConnectionBuilder()
.withUrl('/chat')
.withHubProtocol(new signalR.protocols.msgpack.
MessagePackHubProtocol())
.build();
If you chose to use MessagePack, you also need to add support for it when you register SignalR services:
services
.AddSignalR()
.AddMessagePackProtocol();
Now that we've seen how we can start a conversation, let's look at the SignalR context, where we can get information from...