Skip to content

TonEnfer/SignalP

Repository files navigation

SignalP - SignalR + Protobuf

Overview

SignalP provides Protocol Buffers (a.k.a., protobuf) support in ASP.NET Core SignalR for various purposes - as a protocol, as well as for generating client and server code.

Protocols

Protobuf

SignalP.Protocol.Protobuf provides support for encoding SignalR messages in the Protobuf binary format. Currently, it supports encoding messages generated by protoc (the protobuf compiler) using the official Protobuf support library for C# (Google.Protobuf), as well as encoding primitive types and messages supported by the library protobuf-net.

The semantic structure of messages is very similar to that used when encoding messages in MessagePack protocol, but in binary form they are protobuf messages. The internal structure of messages is described in ProtobufProtocolMessages.proto.

Currently there is only support for C# clients, there is no support for other official and unofficial clients.

Usage

To use the protocol, install the nuget package

dotnet add package SignalP.Protocol.Protobuf

or just copy the source code from folder into your project.

To enable the protocol on the server side, add the following code to Program.cs or Startup.cs depending on which project structure you prefer:

builder.Services.AddSignalR().AddProtobufProtocol();

To enable a protocol on the client side, add it when creating a connection to the hub:

var connection = new HubConnectionBuilder().AddProtobufProtocol().OtherConfiguration().Build();

Code generation

In development...