OutWit.Communication.Client 2.0.1

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

OutWit.Communication.Client

Base client library for the WitRPC framework, providing functionality to connect to WitRPC servers and create dynamic proxies for calling remote services over various transports.

Overview

OutWit.Communication.Client is the core client-side library in the WitRPC ecosystem. It enables your application to act as a WitRPC client that can connect to remote services hosted by a WitRPC server. This package provides the fundamental client logic, including managing the connection, sending requests, receiving responses, and generating proxy objects that implement your service interfaces on the client side. Using these proxies, you can call remote methods and handle server events as if they were happening locally.

Key capabilities of this client library include:

  • Dynamic Service Proxies: The client produces a proxy for your service interface (e.g. IMyService) via client.GetService<IMyService>(). This proxy forwards your method calls to the server and raises server-sent events on the client, supporting a natural, object-oriented usage of remote services (no need to manually serialize calls).

  • Transport Agnostic: The client library works with any supported transport (Named Pipes, TCP, WebSocket, Memory-Mapped Files, REST, etc.). The actual transport is provided by a transport-specific package, but the client API remains the same. You simply configure the desired transport during setup (for example, using .WithTcp(...), .WithWebSocket(...), etc.) and the library handles the details.

  • Serialization & Encryption: The client supports all WitRPC serialization options (JSON by default, or MessagePack/others) and can enable encryption and authentication to match the server's configuration. These are toggled via builder options like .WithJson(), .WithMessagePack(), .WithEncryption(), and .WithAccessToken("token") for providing credentials.

  • Error Handling & Timeouts: You can specify timeouts for connection and calls. The framework will return error statuses or throw exceptions if calls fail or time out, making it easier to handle network issues. The ConnectAsync method allows you to gracefully attempt connections within a specified timeframe.

Under the hood, OutWit.Communication.Client works with the core OutWit.Communication components to format requests and decode responses. In most cases, you will use this package by including a transport-specific client package which depends on it, rather than using OutWit.Communication.Client alone.

Installation

Install-Package OutWit.Communication.Client

Note: In practice, you will typically install a specific client transport package (such as OutWit.Communication.Client.Tcp, OutWit.Communication.Client.WebSocket, etc.) which will automatically include this base library. Choose a transport package that matches the server's transport. For example, if the server uses TCP, install OutWit.Communication.Client.Tcp in the client application.

Basic Usage

To use the WitRPC client, first ensure you have a matching server running (using the corresponding OutWit.Communication.Server.* package). In your client code, you build and connect a client as follows:

using OutWit.Communication.Client;
using OutWit.Communication.Client.Pipes;   // example transport: Named Pipes
using OutWit.Communication.Serializers;
using OutWit.Communication.Client.Encryption;

var client = WitClientBuilder.Build(options =>
{
    // Configure the transport (Named Pipe in this example):
    options.WithNamedPipe("MyAppPipe");
    // Use JSON serialization and enable encryption to match the server:
    options.WithJson();
    options.WithEncryption();
    // If the server requires an access token for authorization:
    // options.WithAccessToken("SecureTokenValue");
});

bool connected = await client.ConnectAsync(TimeSpan.FromSeconds(5));
if (!connected)
{
    Console.Error.WriteLine("Unable to connect to the RPC server.");
    return;
}

// Obtain a proxy to the remote service interface
IMyService service = client.GetService<IMyService>();

// Now you can call methods on the service and subscribe to events as if it were local:
service.SomeMethod("Hello");              
service.SomeEvent += data => Console.WriteLine($"Event from server: {data}");

In this example, we built a client to connect via a named pipe called "MyAppPipe". The server must also be configured to listen on "MyAppPipe" (using OutWit.Communication.Server.Pipes) for the connection to succeed. We enabled JSON serialization and encryption in the client to align with the server's settings. We also demonstrate calling a method SomeMethod on the service and subscribing to an event SomeEvent. The call to SomeMethod will be sent to the server's implementation, and any SomeEvent raised on the server will invoke our console WriteLine on the client side.

Transport Selection: The above used Named Pipes for illustration, but you would use the transport relevant to your scenario. For example, to connect via TCP: use options.WithTcp("server-address", port), or for WebSocket: options.WithWebSocket("ws://server:port/path"). Just ensure the server is using the corresponding server transport with matching parameters (pipe name, port number, URL path, etc.).

Dynamic Proxies: After connecting, calling client.GetService<T>() returns an object of interface T that acts as a live proxy to the server. You do not need to write any networking code: simply call methods on this proxy as you would on a local object. The WitRPC client takes care of packaging the call, sending it to the server, and unwrapping the response. If the server triggers an event, the proxy raises that event on the client side.

Tip: This base client library works behind the scenes. In a typical application, you will primarily interact with the builder (to configure transports/security) and the proxy object. The heavy lifting of managing sockets, threads, or pipe streams is handled internally by this library and the transport plugins.

Further Documentation

See the WitRPC documentation for advanced client usage, including using the source generator (OutWit.Common.Proxy.Generator) for compile-time proxy generation and debugging tips.

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 is compatible.  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 is compatible.  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 is compatible.  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 (6)

Showing the top 5 NuGet packages that depend on OutWit.Communication.Client:

Package Downloads
OutWit.Communication.Client.Tcp

TCP transport client for WitRPC, enabling network communication over TCP sockets (with optional TLS support) to connect to WitRPC servers.

OutWit.Communication.Client.WebSocket

WebSocket transport client for WitRPC, enabling real-time, full-duplex communication over WebSocket connections (great for internet or browser-based clients).

OutWit.Communication.Client.MMF

Memory-mapped file transport client for WitRPC, enabling high-speed inter-process communication via a shared memory region (for on-machine RPC calls).

OutWit.Communication.Client.Pipes

Named Pipes transport client for WitRPC, allowing efficient inter-process communication via named pipes on the local machine (with support for multiple clients).

OutWit.InterProcess.Host

Provides host-side functionality to launch external processes and connect to them via WitRPC, allowing your application to use out-of-process services as if they were local (handles process startup and client proxy generation).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 110 7/5/2025
2.0.0 126 6/6/2025
1.2.0 158 2/28/2025
1.1.1 164 2/1/2025
1.1.0 152 1/25/2025
1.0.2 175 1/11/2025
1.0.0 177 1/2/2025