About this project
MagicOnion is a unified realtime/API framework for the .NET platform and Unity, developed by Cysharp. It combines RPC-style service calls with bi-directional real-time communication in a single framework.
At its core, MagicOnion is built on gRPC, which provides a fast, compact binary transport over HTTP/2. Unlike plain gRPC, however, it treats C# interfaces as the protocol schema. This means developers can share service interfaces directly between server and client projects without writing or maintaining `.proto` (Protocol Buffers IDL) files. Interfaces act as both the API definition and the schema, so the same C# code defines the contract on both sides.
The framework covers two main usage patterns. The first is unary RPC services, comparable to gRPC, WCF, or ASP.NET Core Web API. Service methods return `UnaryResult<T>` or `UnaryResult` and are treated as asynchronous. The second is StreamingHub, a real-time communication service that allows a server to broadcast data to multiple connected clients, similar in role to SignalR, Socket.io, Photon, or UNet. These two features can be used independently or combined in the same application.
Typical use cases described by the project include microservices RPC, API services targeting diverse clients such as Windows WPF applications, Unity games, .NET for iOS/Android, and .NET MAUI, as well as bi-directional real-time communication for games and interactive apps.
Platform support is broad. The server side requires .NET 8 or later. The client side supports .NET 8+, .NET Standard 2.1 and 2.0, .NET Framework 4.6.1 through .NET 8, and Unity 2022.3 LTS or newer on Windows, macOS, iOS, and Android, with both IL2CPP and Mono scripting backends.
Getting started involves adding the `MagicOnion.Server` NuGet package to an ASP.NET Core project, registering the service with `AddMagicOnion()` and mapping it with `MapMagicOnionService()`. A shared interface deriving from `IService<T>` defines the contract, and an implementation class inherits `ServiceBase<T>` and the interface. On the client, the `MagicOnion.Client` package is used to create a gRPC channel and a proxy via `MagicOnionClient.Create<T>()`, after which service methods can be called transparently.
Documentation is available in both English and Japanese. The library is released under the MIT License.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.