MagicOnion
website·Indexed 30 days ago
https://cysharp.github.io/MagicOnionA gRPC-based RPC framework for .NET that enables real-time communication between servers and clients. It features Unary services for simple request-response patterns and StreamingHub for bidirectional real-time communication. The framework supports various platforms including Unity (including experimental WebGL support) and ASP.NET Core Blazor, utilizing MessagePack for serialization.
What's inside MagicOnion
- MagicOnion is an open-source RPC framework (MIT licensed) that provides a unified development experience by using .NET/C# types for service definitions and transparent proxy generation. It is built on ASP.NET Core and utilizes gRPC over HTTP/2 for efficient communication and MessagePack for high-performance binary serialization.
Overview of MagicOnion features and architecture
MagicOnion is an open-source library (MIT license) that provides a frictionless development experience for building RPC-style API services. It allows for unified service definitions using .NET/C# types and generates transparent proxies for communication.
Key architectural foundations include:
- Server: Built on ASP.NET Core, leveraging the .NET ecosystem.
- Transport: Based on gRPC over HTTP/2 for efficient communication and interoperability.
- Serialization: Uses MessagePack for efficient binary serialization, with available extension points for customization.
- Client Support: Compatible with .NET and Unity.
Overview of MagicOnion RPC Framework
MagicOnion is a modern RPC framework for the .NET platform designed for bi-directional real-time communications and RPC mechanisms. It is built on top of gRPC (HTTP/2 binary transport) but differs by using C# interfaces as the protocol schema instead of.protofiles, allowing for seamless code sharing between C# projects. It is suitable for replacing or implementing microservices (gRPC), legacy WCF services, ASP.NET Core MVC APIs for Unity/Xamarin/Windows, and real-time communication systems like SignalR, Socket.io, Photon, or UNet.Introduction to MagicOnion RPC Framework
MagicOnion is a modern RPC framework for the .NET platform that provides bi-directional real-time communications (similar to SignalR and Socket.io) and RPC mechanisms (similar to WCF and web-based APIs). It is built on top of gRPC (HTTP/2 binary transport) but eliminates the need for.proto(Protocol Buffers IDL) files by treating C# interfaces as the protocol schema, allowing for seamless code sharing between C# projects.Overview of MagicOnion features and architecture
MagicOnion is an open-source RPC library under the MIT license designed for .NET and Unity. It provides a unified development experience by using .NET/C# types for service definitions and transparent proxy generation.
Key technical capabilities include:
- Real-time Communication: Supports server-to-client notifications, concurrent calls from multiple clients, connection loss detection via heartbeats, and multi-client broadcasting using Redis or NATS.
- Infrastructure: Built on top of ASP.NET Core, leveraging the .NET ecosystem.
- Transport & Serialization: Uses gRPC over HTTP2 for efficient communication and interoperability, and MessagePack for high-performance binary serialization (with available serialization extension points).
Overview of MagicOnion RPC Framework
MagicOnion is a modern RPC framework for the .NET platform and Unity that provides bidirectional real-time communication. It is built on gRPC and uses HTTP/2 for fast, compact network transport. Unlike standard gRPC, MagicOnion uses C# interfaces as the protocol schema, eliminating the need for.proto(Protocol Buffers IDL) files and allowing direct code sharing between C# projects. It utilizes MessagePack for C# to serialize arguments and return values, supporting .NET primitives and complex types.Overview of MagicOnion RPC Framework
MagicOnion is a modern RPC framework for the .NET platform and Unity that provides bi-directional real-time communications and RPC mechanisms. It is built on top of gRPC (HTTP/2) but differs by using C# interfaces as the protocol schema instead of.proto(Protocol Buffers) files, enabling seamless code sharing between C# projects. It uses MessagePack for C# for the serialization of call arguments and return values.Overview of MagicOnion RPC Framework
MagicOnion is a modern RPC framework for the .NET platform that enables bi-directional real-time communication and RPC mechanisms. It is built on top of gRPC (using HTTP/2 binary transport) but eliminates the need for.proto(Protocol Buffers IDL) files by treating C# interfaces as the protocol schema. This allows for seamless code sharing between C# projects. It is suitable for replacing or implementing microservices (gRPC), legacy WCF services (WinForms/WPF), API services (ASP.NET Core MVC for Unity/Xamarin), and real-time communication systems (SignalR, Socket.io, Photon, or UNet).Overview of MagicOnion RPC Framework
MagicOnion is a modern RPC framework providing bidirectional real-time communication for the .NET platform and Unity. It is built on gRPC and uses HTTP/2 for fast, compact network transport. Unlike standard gRPC, MagicOnion uses C# interfaces as the protocol schema, eliminating the need for.proto(Protocol Buffers IDL) files and allowing direct code sharing between C# projects. It utilizes MessagePack for C# to serialize arguments and return values, supporting .NET primitives and complex types.Choose between MagicOnion Unary and StreamingHub services
MagicOnion provides two API implementation styles for defining RPC-style APIs: Unary and StreamingHub.
- Unary: A simple HTTP POST request that handles one request and one response at a time. Recommended for general APIs (replacing REST or Web API) where server-to-client notifications are not required.
- StreamingHub: A bidirectional communication system using a persistent connection to exchange messages between client and server. Recommended for real-time features such as chat notifications or game position synchronization, serving as an alternative to polling or long-polling.
Understand MagicOnion Heartbeat mechanism and HTTP/2 PING frames
MagicOnion implements its own heartbeat mechanism instead of relying on HTTP/2 PING frames. This is because load balancers in a network path may intercept and respond to PING frames themselves, preventing the PING from reaching the MagicOnion server and failing to verify the actual end-to-end connection. MagicOnion's heartbeat ensures connectivity by explicitly sending and receiving data between the server and client.Understand MagicOnion Heartbeat vs HTTP/2 PING
MagicOnion implements its own heartbeat mechanism instead of relying on HTTP/2 PING frames. This is because load balancers in a network path may intercept and respond to PING frames themselves, preventing the PING from reaching the actual MagicOnion server. By using an explicit data-exchange heartbeat, MagicOnion ensures the connection is alive all the way to the application server.