hrpc.net 1.0.0

dotnet add package hrpc.net --version 1.0.0
                    
NuGet\Install-Package hrpc.net -Version 1.0.0
                    
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="hrpc.net" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="hrpc.net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="hrpc.net" />
                    
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 hrpc.net --version 1.0.0
                    
#r "nuget: hrpc.net, 1.0.0"
                    
#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 hrpc.net@1.0.0
                    
#: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=hrpc.net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=hrpc.net&version=1.0.0
                    
Install as a Cake Tool

hrpc.net

a small hrpc utility library. only supports client-side usage for now

Documentation

Requests

var messageRequest = new Message() { content: "Hi!" };

HttpClient client = ...;

// if you need to add headers (for authorization, for example)
client.DefaultRequestHeaders.Add("Authorization", "token");

await client.HrpcUnaryAsync<Message, Empty>("http://localhost:2289/chat.Chat/SendMessage", messageRequest);

Streams

var stream = new StreamClient<Message>();

// if you need to add headers
var stream = new StreamClient<Message>(new() { { "Authorization", "token" } });

await client.Connect("http://localhost:2289/chat.Chat/StreamMessages", new Chat.Empty());

while (client.State == WebSocketState.Open)
{
    var message = await client.Read();
    _ = HandleMessageReceived(message);
}

Console.WriteLine($"Stream client closed with status {client.CloseStatus}!");

Serializing / Deserializing

// usage in HTTP requests
byte[] data = ...;
int statusCode = ...;
MyClass parsed = Proto.Deserialize<MyClass>(data, statusCode); // throws HrpcError if statusCode != 200

// usage in streams
byte[] data = ...;
MyClass parsed = Proto.Deserialize<MyClass>(data); // throws HrpcError if serialized message begins with 1 (error)

Errors

Any errors thrown by this library are subclasses of HrpcError.

public class HrpcError : Exception
{
    public readonly string Identifier;
    public readonly string HumanMessage;
    public readonly byte[] Details;
}

public class UnknownHrpcError : HrpcError {}
public class InternalServerError : HrpcError {}

public class RateLimited : HrpcError {
    public readonly uint RetryAfter;
}

public class NotFound : HrpcError {}
public class NotImplemented : HrpcError {}
public class Unavailable : HrpcError {}
public class BadUnaryRequest : HrpcError {}
public class BadStreamingRequest : HrpcError {}

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on hrpc.net:

Package Downloads
harmony-dotnet-sdk

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 979 12/18/2021