Install VoltRpc
Add to your project's csproj
:
<ItemGroup>
<PackageReference Include="VoltRpc" Version="3.2.0" />
<PackageReference Include="VoltRpc.Proxy.Generator" Version="2.2.0" />
</ItemGroup>
And Start Using!
[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<ITestInterface>(test);
host.StartListening().ConfigureAwait(false);
//Client
Client client = new TCPClient(ip);
client.AddService<ITestInterface>();
client.Connect();
//Now we can call to method like it was normal C#
TestProxy proxy = new(client);
proxy.DoSomethingCool();
}