Git Product home page Git Product logo

ipcserviceframework's Introduction

CI build Stable build
Build Status Build Status

IpcServiceFramework

A .NET Core 3.1 based lightweight framework for efficient inter-process communication. Named pipeline and TCP support out-of-the-box, extensible with other protocols.

NuGet packages

Name Purpose Status
JKang.IpcServiceFramework.Client.NamedPipe Client SDK to consume IPC service over Named pipe NuGet version
JKang.IpcServiceFramework.Client.Tcp Client SDK to consume IPC service over TCP NuGet version
JKang.IpcServiceFramework.Hosting.NamedPipe Server SDK to run Named pipe IPC service endpoint NuGet version
JKang.IpcServiceFramework.Hosting.Tcp Server SDK to run TCP IPC service endpoint NuGet version

Usage

  1. Create an interface as service contract and package it in an assembly to be referenced by server and client applications, for example:

    public interface IInterProcessService
    {
        string ReverseString(string input);
    }
  2. Implement the service in server application, for example:

    class InterProcessService : IInterProcessService
    {
        public string ReverseString(string input)
        {
            char[] charArray = input.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }
    }
  3. Install the following NuGet packages in server application:

    > Install-Package Microsoft.Extensions.Hosting
    > Install-Package JKang.IpcServiceFramework.Hosting.NamedPipe
  4. Register the service implementation and configure IPC endpoint(s):

    class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }
    
        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureServices(services =>
                {
                    services.AddScoped<IInterProcessService, InterProcessService>();
                })
                .ConfigureIpcHost(builder =>
                {
                    // configure IPC endpoints
                    builder.AddNamedPipeEndpoint<IInterProcessService>(pipeName: "pipeinternal");
                })
                .ConfigureLogging(builder =>
                {
                    // optionally configure logging
                    builder.SetMinimumLevel(LogLevel.Information);
                });
    }
  5. Install the following NuGet package in client application:

    > Install-Package JKang.IpcServiceFramework.Client.NamedPipe
  6. Invoke the server

    // register IPC clients
    ServiceProvider serviceProvider = new ServiceCollection()
        .AddNamedPipeIpcClient<IInterProcessService>("client1", pipeName: "pipeinternal")
        .BuildServiceProvider();
    
    // resolve IPC client factory
    IIpcClientFactory<IInterProcessService> clientFactory = serviceProvider
        .GetRequiredService<IIpcClientFactory<IInterProcessService>>();
    
    // create client
    IIpcClient<IInterProcessService> client = clientFactory.CreateClient("client1");
    
    string output = await client.InvokeAsync(x => x.ReverseString(input));

FAQs

ipcserviceframework's People

Contributors

adospace avatar anthonypcole avatar brightness007 avatar cklutz avatar gaulomatic avatar gsuberland avatar hoochharp avatar jacqueskang avatar jeremywu917 avatar jorisvergeer avatar lakritzator avatar lindexi avatar logiclrd avatar luhis avatar michaelrall avatar mschriscooper avatar nzbart avatar spaceisfun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.