Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/voltstro-studios/voltrpc
VoltRpc - An RPC library which is designed to be both simple to use and fast.
https://github.com/voltstro-studios/voltrpc
csharp csharp-rpc csharp-sourcegenerator csharp-tcp dotnet dotnet-core dotnet-standard dotnet6 interprocess-communication ipc named-pipes rpc rpc-library tcp
Last synced: about 2 months ago
JSON representation
VoltRpc - An RPC library which is designed to be both simple to use and fast.
- Host: GitHub
- URL: https://github.com/voltstro-studios/voltrpc
- Owner: Voltstro-Studios
- License: mit
- Created: 2021-07-15T14:42:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-24T11:51:12.000Z (about 1 year ago)
- Last Synced: 2024-01-25T10:53:05.009Z (about 1 year ago)
- Topics: csharp, csharp-rpc, csharp-sourcegenerator, csharp-tcp, dotnet, dotnet-core, dotnet-standard, dotnet6, interprocess-communication, ipc, named-pipes, rpc, rpc-library, tcp
- Language: C#
- Homepage: https://projects.voltstro.dev/VoltRpc/
- Size: 1010 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# VoltRpc
[![License](https://img.shields.io/github/license/Voltstro-Studios/VoltRpc)](/LICENSE.md)
[![NuGet](https://img.shields.io/nuget/v/VoltRpc?label=NuGet)](https://www.nuget.org/packages/VoltRpc/)
[![NuGet Download Count](https://img.shields.io/nuget/dt/VoltRpc?label=Downloads&logo=nuget&color=blue&logoColor=blue)](https://www.nuget.org/packages/VoltRpc/)
[![Build Status](https://img.shields.io/azure-devops/build/Voltstro-Studios/63163ef8-da1d-42b6-b8b9-689420a730e5/9?logo=azure-pipelines)](https://dev.azure.com/Voltstro-Studios/VoltRpc/_build/latest?definitionId=9&branchName=master)
[![Docs Status](https://img.shields.io/uptimerobot/status/m794227043-7e2bf837661fcd75d2af6804?label=Docs)](https://projects.voltstro.dev/VoltRpc/latest/)
[![Discord](https://img.shields.io/badge/Discord-Voltstro-7289da.svg?logo=discord)](https://discord.voltstro.dev)VoltRpc - An RPC library which is designed to be both simple to use and fast.
## Features
- Its fast (See the [benchmarks](#benchmarks))
- Supports all built-in C# value types, including:
- `Bool`
- `Byte`
- `Char`
- `Decimal`
- `Double`
- `Float`
- `Int`
- `Long`
- `SByte`
- `Short`
- `UInt`
- `ULong`
- `UShort`
- Supports these built-in .NET types: (More to be added)
- `String`
- `DateTime`
- `TimeSpan`
- `Uri`
- `Guid`
- `Vector2`
- `Vector3`
- `Vector4`
- `Plane`
- `Quaternion`
- `Matrix3x2`
- `Matrix4x4`
- Supports arrays for any type
- Easily support [custom types](https://projects.voltstro.dev/VoltRpc/articles/types/#custom-types) by implementing a `TypeReadWriter`
- Proxy generated by using a [.NET Source Generator](https://projects.voltstro.dev/VoltRpc/articles/proxy-generation/)
- Simple to use## Getting Started
### Installation
VoltRpc can be installed from [NuGet](https://nuget.org/packages/VoltRpc). You will also need the proxy generator (also on [NuGet](https://www.nuget.org/packages/VoltRpc.Proxy.Generator/)).
```xml
```
### Example
For a more in-depth example, see the [Overview](https://projects.voltstro.dev/VoltRpc/articles/overview/) or [Setup](https://projects.voltstro.dev/VoltRpc/articles/setup/).
There is also a [demo project](https://github.com/Voltstro-Studios/VoltRpc/tree/master/src/Demo) included.
```csharp
[GenerateProxy(GeneratedName = "TestProxy")]
public interface ITestInterface
{
public void DoSomethingCool();
public int GetTheCoolValue();
}public class TestInterface : ITestInterface
{
public void DoSomethingCool()
{
Console.WriteLine("Something Cool!");
}public int GetTheCoolValue()
{
return 69;
}
}public class Program
{
IPEndPoint ip = new(IPAddress.Loopback, 7767);TestInterface test = new();
//Host
Host host = new TCPHost(ip);
host.AddService(test);
host.StartListening().ConfigureAwait(false);//Client
Client client = new TCPClient(ip);
client.AddService();
client.Connect();//Now we can call to method like it was normal C#
TestProxy proxy = new(client);
proxy.DoSomethingCool();
}
```## Benchmarks
``` ini
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1826 (21H2)
Intel Core i5-10600KF CPU 4.10GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.302
[Host] : .NET 6.0.7 (6.0.722.32202), X64 RyuJIT
Job-TDLHXN : .NET 6.0.7 (6.0.722.32202), X64 RyuJITJit=Default Platform=AnyCpu Runtime=.NET 6.0
```![Pipes Non-Array](media/PipesBenchmarkNonArrays.png)
![Pipes Non-Array](media/PipesBenchmarkArrays.png)
(Currently, the in-built arrays are quite a lot slower, we are looking into fixing this in a later release)
| Method | message | array | Mean | Error | StdDev |
|--------------------- |------------- |-------------- |-----------------:|---------------:|---------------:|
| **BasicVoid** | **?** | **?** | **6.311 μs** | **0.0517 μs** | **0.0432 μs** |
| BasicReturn | ? | ? | 7.444 μs | 0.0589 μs | 0.0551 μs |
| ArrayReturn | ? | ? | 21.389 μs | 0.3943 μs | 0.6695 μs |
| ArrayFast | ? | ? | 1,579.432 μs | 10.1223 μs | 9.4684 μs |
| **BasicParameterVoid** | **Hello World!** | **?** | **7.128 μs** | **0.0390 μs** | **0.0346 μs** |
| BasicParameterReturn | Hello World! | ? | 8.287 μs | 0.0364 μs | 0.0304 μs |
| **ArrayParameterVoid** | **?** | **Byte[25]** | **18.423 μs** | **0.3675 μs** | **0.6140 μs** |
| ArrayParameterReturn | ? | Byte[25] | 28.647 μs | 0.5643 μs | 0.9112 μs |
| **ArrayParameterVoid** | **?** | **Byte[8294400]** | **2,705,942.687 μs** | **11,965.3253 μs** | **11,192.3727 μs** |
| ArrayParameterReturn | ? | Byte[8294400] | 5,416,337.679 μs | 21,036.1040 μs | 18,647.9583 μs |For more info on these benchmarks see [Benchmarks](https://projects.voltstro.dev/VoltRpc/articles/benchmarks/).
## Authors
**Voltstro** - *Initial work* - [Voltstro](https://github.com/Voltstro)
## License
This project is licensed under the MIT license – see the [LICENSE.md](https://github.com/Voltstro-Studios/VoltRpc/blob/master/LICENSE.md) file for details.
## Credits
- [Mirror](https://github.com/vis2k/Mirror)
- [`NetworkReader.cs`](https://github.com/vis2k/Mirror/tree/50e6bb11016257c505c39380b6aa7f957bb6048e/Assets/Mirror/Runtime/NetworkReader.cs) used as a base for [`BufferedReader.cs`](/src/VoltRpc/IO/BufferedReader.cs)
- [`NetworkWriter.cs`](https://github.com/vis2k/Mirror/tree/50e6bb11016257c505c39380b6aa7f957bb6048e/Assets/Mirror/Runtime/NetworkWriter.cs) used as a base for [`BufferedWriter.cs`](/src/VoltRpc/IO/BufferedWriter.cs)
- Parts of [`BufferedStream.cs`](https://github.com/dotnet/runtime/blob/release/5.0/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs) from the .NET Runtime was also used in the reader.