OutWit.Communication.Client
1.0.0
See the version list below for details.
dotnet add package OutWit.Communication.Client --version 1.0.0
NuGet\Install-Package OutWit.Communication.Client -Version 1.0.0
<PackageReference Include="OutWit.Communication.Client" Version="1.0.0" />
paket add OutWit.Communication.Client --version 1.0.0
#r "nuget: OutWit.Communication.Client, 1.0.0"
// Install OutWit.Communication.Client as a Cake Addin #addin nuget:?package=OutWit.Communication.Client&version=1.0.0 // Install OutWit.Communication.Client as a Cake Tool #tool nuget:?package=OutWit.Communication.Client&version=1.0.0
OutWit.Communication.Client
Overview
The OutWit.Communication.Client
library provides a robust framework for client-side communication in the WitCom ecosystem. With features like encryption, token-based authorization, and flexible serialization, it enables secure and efficient communication with WitCom servers.
Features
1. Authorization
- AccessTokenProviderPlain: No token, suitable for public or unauthenticated scenarios.
- AccessTokenProviderStatic: Static token for secure, predefined access.
Example:
var client = WitComClientBuilder.Build(options =>
{
options.WithAccessToken("your-access-token");
});
2. Encryption
- EncryptorClientPlain: No encryption for lightweight communication.
- EncryptorClientGeneral: RSA/AES encryption for secure data exchange.
Example:
var client = WitComClientBuilder.Build(options =>
{
options.WithEncryption();
});
3. Serialization
- JSON: Default format, ideal for debugging and compatibility.
- MessagePack: High-performance, compact binary serialization.
Example:
var client = WitComClientBuilder.Build(options =>
{
options.WithJson();
});
// Or for MessagePack:
var client = WitComClientBuilder.Build(options =>
{
options.WithMessagePack();
});
4. Logging and Debugging
Integrate custom logging for debugging and monitoring:
var client = WitComClientBuilder.Build(options =>
{
options.WithLogger(new ConsoleLogger());
});
5. Timeout Configuration
Set request and response timeouts for client operations:
var client = WitComClientBuilder.Build(options =>
{
options.WithTimeout(TimeSpan.FromSeconds(30));
});
6. Proxy for Services
Automatically generates a proxy to interact with server-side services using interfaces:
var service = client.GetService<IMyService>();
service.SomeMethod();
Installation
Install the package via NuGet. Note: You also need to install the specific transport package you intend to use (e.g., OutWit.Communication.Client.Tcp
, OutWit.Communication.Client.WebSocket
, etc.):
Install-Package OutWit.Communication.Client
Getting Started
Basic Setup
var client = WitComClientBuilder.Build(options =>
{
options.WithAccessToken("my-access-token");
options.WithEncryption();
options.WithJson();
options.WithTimeout(TimeSpan.FromSeconds(10));
});
await client.ConnectAsync(TimeSpan.FromSeconds(5), CancellationToken.None);
Sending Requests
var request = new WitComRequest
{
MethodName = "MyMethod",
Parameters = new object[] { 1, "parameter" }
};
var response = await client.SendRequest(request);
Console.WriteLine(response.Status);
Handling Events
The client supports events for callbacks and disconnections:
client.CallbackReceived += request =>
{
Console.WriteLine("Callback received!");
};
client.Disconnected += _ =>
{
Console.WriteLine("Disconnected from server");
};
API Reference
WitComClient
The core class for client-side communication.
Key Methods:
ConnectAsync
: Establishes a connection to the server.SendRequest
: Sends a request and receives a response.GetService
: Generates a client-side proxy for a server-side service.
Events:
CallbackReceived
: Triggered when a server callback is received.Disconnected
: Triggered when the client disconnects from the server.
WitComClientBuilder
A fluent API for configuring and creating WitComClient
instances.
Configuration Options:
.WithAccessToken
: Sets the access token for authentication..WithEncryption
: Enables encryption for secure communication..WithJson
: Configures JSON serialization..WithMessagePack
: Configures MessagePack serialization..WithTimeout
: Sets the timeout duration.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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. |
-
net5.0
- OutWit.Communication (>= 1.0.0)
-
net6.0
- OutWit.Communication (>= 1.0.0)
-
net7.0
- OutWit.Communication (>= 1.0.0)
-
net8.0
- OutWit.Communication (>= 1.0.0)
-
net9.0
- OutWit.Communication (>= 1.0.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on OutWit.Communication.Client:
Package | Downloads |
---|---|
OutWit.Communication.Client.Tcp
TCP client transport for WitCom - OutWit.Communication - the easiest and most natural way to communicate with .Net processes/services/clients. |
|
OutWit.Communication.Client.WebSocket
Web Socket client transport for WitCom - OutWit.Communication - the easiest and most natural way to communicate with .Net processes/services/clients. |
|
OutWit.Communication.Client.MMF
Memory Mapped File client transport for WitCom - OutWit.Communication - the easiest and most natural way to communicate with .Net processes/services/clients. |
|
OutWit.Communication.Client.Pipes
Named Pipe client transport for WitCom - OutWit.Communication - the easiest and most natural way to communicate with .Net processes/services/clients. |
|
OutWit.InterProcess.Host
Inter Process Host logic |
GitHub repositories
This package is not used by any popular GitHub repositories.