Skip to content

Implementation of named pipes stream to abstract the complexity. Allow you to use inter-process communication in a simple way

Notifications You must be signed in to change notification settings

rcarubbi/Carubbi.Communication

Repository files navigation

Carubbi.Communication

Implementation of named pipes stream to abstract the complexity. Allow you to use inter-process communication in a simple way

1. Server sample:

Echo Service:

public class EchoService : Server<string, string>
{
    public EchoService()
    : base(nameof(EchoService))
    {

    }

    protected override string ProcessRequest(string requestMessage)
    {
        Console.WriteLine($"Message received: {requestMessage}");
        return $"Message sent: {requestMessage}";
    }

    protected override void BeforeStart()
    {
        Console.WriteLine("Server starting...");
    }
}

Server App:

var service = new EchoService();
service.Start();

2. Client Sample

Service Callback:

public class EchoServiceCallback : IObserver<string>
{
   public void OnNext(string value)
   {
       Console.WriteLine(value);
   }

   public void OnError(Exception error)
   {
       Console.WriteLine(error.Message);
   }

   public void OnCompleted()
   {
       Console.WriteLine("Request Completed");
   }
}

Client App:

using (var client = new Client<string, string>("EchoService"))
{
    client.BeforeConnect += (sender, eventArgs) => Console.WriteLine("Connecting...");
    client.AfterEnd += (sender, eventArgs) => Console.WriteLine("Disconected.");
    client.Subscribe(new EchoServiceCallback());
    client.Connect();
   
    Console.WriteLine("Type your message:");
    var message = Console.ReadLine();
    client.SendRequest(new List<string> { message });
} 

About

Implementation of named pipes stream to abstract the complexity. Allow you to use inter-process communication in a simple way

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages