MagicOnion.Serialization.MessagePack 7.0.7

dotnet add package MagicOnion.Serialization.MessagePack --version 7.0.7
                    
NuGet\Install-Package MagicOnion.Serialization.MessagePack -Version 7.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MagicOnion.Serialization.MessagePack" Version="7.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MagicOnion.Serialization.MessagePack" Version="7.0.7" />
                    
Directory.Packages.props
<PackageReference Include="MagicOnion.Serialization.MessagePack" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MagicOnion.Serialization.MessagePack --version 7.0.7
                    
#r "nuget: MagicOnion.Serialization.MessagePack, 7.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MagicOnion.Serialization.MessagePack@7.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MagicOnion.Serialization.MessagePack&version=7.0.7
                    
Install as a Cake Addin
#tool nuget:?package=MagicOnion.Serialization.MessagePack&version=7.0.7
                    
Install as a Cake Tool

MagicOnion

Build Build Canary Release Releases

Unified Realtime/API framework for .NET platform and Unity.

📖 Documentation (English) | Documentation (Japanese)

About MagicOnion

MagicOnion is a modern RPC framework for .NET platform that provides bi-directional real-time communications such as SignalR and Socket.io and RPC mechanisms such as WCF and web-based APIs.

This framework is based on gRPC, which is a fast and compact binary network transport for HTTP/2. However, unlike plain gRPC, it treats C# interfaces as a protocol schema, enabling seamless code sharing between C# projects without .proto (Protocol Buffers IDL).

image

Interfaces are schemas and provide API services, just like the plain C# code

image

Using the StreamingHub real-time communication service, the server can broadcast data to multiple clients

MagicOnion can be adopted or replaced in the following use cases:

  • RPC services such as gRPC, used by Microservices, and WCF, commonly used by WinForms/WPF
  • API services such as ASP.NET Core Web API targeting various platforms and clients such as Windows WPF applications, Unity games, .NET for iOS, Android, and .NET MAUI
  • Bi-directional real-time communication such as Socket.io, SignalR, Photon and UNet

MagicOnion supports API services and real-time communication, making it suitable for various use cases. You can use either of these features separately, but configurations that combine both are also supported.

More information about MagicOnion can be found in the MagicOnion documentation.

Supported Platforms

MagicOnion is designed to run on various .NET platforms. The requirements for the server and client are as follows.

Server-side

MagicOnion server requires .NET 8+.

Client-side

MagicOnion client supports a wide range of platforms, including .NET Framework 4.6.1 to .NET 8 as well as Unity.

  • .NET 8+
  • .NET Standard 2.1, 2.0
  • Unity 2022.3 (LTS) or newer
    • Windows, macOS, iOS, Android
    • IL2CPP, Mono

Quick Start

This guide shows how to create a simple MagicOnion server and client. The server provides a simple service that adds two numbers, and the client calls the service to get the result.

MagicOnion provides RPC services like Web API and StreamingHub for real-time communication. This section implements an RPC service like Web API.

Server-side: Defining and Implementing a Service

At first, create a MagicOnion server project and define and implement a service interface.

1. Setting up a gRPC server project for MagicOnion

To start with a Minimal API project (see: Tutorial: Create a minimal web API with ASP.NET Core), create a project from the ASP.NET Core Empty template. Add the NuGet package MagicOnion.Server to the project. If you are using the .NET CLI tool to add it, run the following command:

dotnet add package MagicOnion.Server

Open Program.cs and add some method calls to Services and app.

using MagicOnion;
using MagicOnion.Server;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMagicOnion(); // Add this line(MagicOnion.Server)

var app = builder.Build();

app.MapMagicOnionService(); // Add this line

app.Run();

At this point, you are ready to use MagicOnion in your server project.

2. Implementing a Unary Service

Add the IMyFirstService interface to share it between the server and the client. In this case, the namespace that contains the shared interface is MyApp.Shared.

The return type must be UnaryResult<T> or UnaryResult, which is treated as an asynchronous method like Task or ValueTask.

using System;
using MagicOnion;

namespace MyApp.Shared
{
    // Defines .NET interface as a Server/Client IDL.
    // The interface is shared between server and client.
    public interface IMyFirstService : IService<IMyFirstService>
    {
        // The return type must be `UnaryResult<T>` or `UnaryResult`.
        UnaryResult<int> SumAsync(int x, int y);
    }
}

Add a class that implements the IMyFirstService interface. The client calls this class to process the request.

using MagicOnion;
using MagicOnion.Server;
using MyApp.Shared;

namespace MyApp.Services;

// Implements RPC service in the server project.
// The implementation class must inherit `ServiceBase<IMyFirstService>` and `IMyFirstService`
public class MyFirstService : ServiceBase<IMyFirstService>, IMyFirstService
{
    // `UnaryResult<T>` allows the method to be treated as `async` method.
    public async UnaryResult<int> SumAsync(int x, int y)
    {
        Console.WriteLine($"Received:{x}, {y}");
        return x + y;
    }
}

The service definition and implementation are now complete.

It is now ready to start the MagicOnion server. You can start the MagicOnion server by pressing the F5 key or using the dotnet run command. At this time, note the URL displayed when the server starts, as it will be the connection destination for the client.

Client-side: Calling a Unary Service

Create a Console Application project and add the NuGet package MagicOnion.Client.

Share the IMyFirstService interface and use it in the client. You can share the interface in various ways, such as file links, shared libraries, or copy & paste...

In the client code, create a client proxy using MagicOnionClient based on the shared interface and call the service transparently.

At first, create a gRPC channel. The gRPC channel abstracts the connection, and you can create it using the GrpcChannel.ForAddress method. Then, create a MagicOnion client proxy using the created channel.

using Grpc.Net.Client;
using MagicOnion.Client;
using MyApp.Shared;

// Connect to the server using gRPC channel.
var channel = GrpcChannel.ForAddress("https://localhost:5001");

// Create a proxy to call the server transparently.
var client = MagicOnionClient.Create<IMyFirstService>(channel);

// Call the server-side method using the proxy.
var result = await client.SumAsync(123, 456);
Console.WriteLine($"Result: {result}");

When using MagicOnion client in Unity applications, see also Works with Unity.

More detailed documentation

More information about MagicOnion can be found in the MagicOnion documentation.

License

This library is under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on MagicOnion.Serialization.MessagePack:

Package Downloads
MagicOnion.Shared

Provides shared classes and interfaces used by MagicOnion server and client. Unified Realtime/API framework for .NET platform and Unity.

MagicOnion.Client

MagicOnion client-side runtime library. Unified Realtime/API framework for .NET platform and Unity.

MagicOnion.Server

MagicOnion server built on top of ASP.NET Core. Unified Realtime/API framework for .NET platform and Unity.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on MagicOnion.Serialization.MessagePack:

Repository Stars
Cysharp/GrpcWebSocketBridge
Yet Another gRPC over HTTP/1 using WebSocket implementation, primarily targets .NET platform.
Version Downloads Last Updated
7.0.7 1,014 12/2/2025
7.0.6 64,603 7/29/2025
7.0.5 92,800 6/25/2025
7.0.4 738,566 5/1/2025
7.0.3 23,061 4/14/2025
7.0.2 47,893 2/10/2025
7.0.1 330,847 2/3/2025
7.0.0 6,633 1/31/2025
7.0.0-rc4 1,194 1/22/2025
7.0.0-rc3 364 1/10/2025
7.0.0-rc2 243 1/9/2025
7.0.0-rc1 243 1/8/2025
7.0.0-preview.10 2,930 9/20/2024
7.0.0-preview.9 462 9/20/2024
7.0.0-preview.8 115 9/20/2024
7.0.0-preview.7 7,398 9/6/2024
7.0.0-preview.6 3,078 8/7/2024
7.0.0-preview.5 2,605 7/3/2024
7.0.0-preview.4 1,426 6/21/2024
7.0.0-preview.3 130 6/21/2024
7.0.0-preview.2 119 6/21/2024
7.0.0-preview.1 147 6/19/2024
6.1.7 32,092 2/12/2025
6.1.6 127,688 11/6/2024
6.1.5 17,878 10/16/2024
6.1.4 93,105 7/17/2024
6.1.3 54,218 5/8/2024
6.1.2 35,171 3/22/2024
6.1.1 27,095 3/21/2024
6.1.0 659 3/21/2024
6.0.0 58,747 1/11/2024