Skip to content

MessageCommunicator is a library + testing Gui for message-based communication. The library is based on .Net Standard 2.1. The Gui is build using C# and Avalonia, therefore it supports the desktop environments on Windows, Linux and Mac.

License

RolandKoenig/MessageCommunicator

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

MessageCommunicator

About

MessageCommunicator is a .Net library + testing Gui for message-based communication. The library can be integrated into .Net Standard 2.1 oder 2.0 compatible frameworks. It is distributed using Nuget. The Gui is build using C# and Avalonia, therefore it supports the desktop environments on Windows, Linux and Mac.

Quick Links

Build

Build and test (.Net 6.0.x on Ubuntu) Build and test (.Net 6.0.x on Windows)

Library

The library is designed to be cross-platform, asynchronous and to use as less object allocations as possible. In the following example we are creating a channel which listens for incoming tcp connections on port 12000. Messages are encoded by UTF8 and use ## as end sign.

// Create and start passive channel (listens for incoming tcp connection)
var passiveTcpChannel = new MessageChannel(
    new TcpPassiveByteStreamHandlerSettings(IPAddress.Loopback, 12000),
    new EndSymbolsMessageRecognizerSettings(Encoding.UTF8, "##"),
    (message) =>
    {
        Console.WriteLine($"Received message on passive channel: {message}");
    });
await passiveTcpChannel.StartAsync();

In the following example we are doing almost the same. The only difference is that we do not listen. Here we are connecting to port 12000 on the localhost.

// Create and start send channel
var activeTcpChannel = new MessageChannel(
    new TcpActiveByteStreamHandlerSettings(IPAddress.Loopback, 12000), 
    new EndSymbolsMessageRecognizerSettings(Encoding.UTF8, "##"),
    (message) =>
    {
        Console.WriteLine($"Received message on active channel: {message}");
    });
await activeTcpChannel.StartAsync();

Sending a message is as easy as:

await activeTcpChannel.SendAsync("Message 1 from active to passive...");

Features

The library provides the following features:

  • Automated reconnect handling (you don't have to care about the connection)
  • Message recognition (e. g. by end symbol, by fixed length, etc.)
  • String encoding
  • Different channel types (TCP, UDP, SerialPort)

Gui

Inside the testing Gui you can manage multiple profiles. Each profile has its own configuration for which stream it uses (tcp active, tcp passive. ...) and which message recognizer it uses (endsymbols, etc.). The Gui also displays all logging messages which come through the logger of the corresponding message channel.

alt text

alt text

Project is based on...

MessageCommunicator GUI is based on .Net 5 and meant to be cross-platform. The Library supports .Net Standard 2.0 and above.

The project is based on following technologies / projects:

  • Avalonia: Cross-platform, Xaml based UI framework
  • Avalonia.IconPacks: A good collection of free vector icons ready to be used in Avalonia applications
  • Inconsolata: Inconsolata is an open-source font created by Raph Levien and released under the SIL Open Font License.
  • Light.GuardClauses: A lightweight .NET library for expressive Guard Clauses
  • Markdown.Avalonia: Markdown.Avalonia is a portted version of MdXaml for Avalonia UI. It can render Markdown with avalonia.
  • ReactiveUI: Cross-platform mvvm framework. Avalonia has additional integration for ReactiveUI
  • StringFormatter: A copy/paste ready alternative to StringBuilder. StringFormatter is optimized for less object allocations
  • Svg.Skia: SVG rendering library with good Avalonia integration.

About

MessageCommunicator is a library + testing Gui for message-based communication. The library is based on .Net Standard 2.1. The Gui is build using C# and Avalonia, therefore it supports the desktop environments on Windows, Linux and Mac.

Resources

License

Stars

Watchers

Forks

Packages

No packages published