Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

OpenByteDev/DynamicServices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DynamicServices

NetMQ NuGet version

Installation

You can download DynamicServices via NuGet.

Client - Host

var address = @"localhost";
var port = 5000;
using (var host = new ServiceHost(address, port)) {
    host.RegisterService<EchoService>();
    host.Start();
    using (var client = new ServiceClient(address, port)) {
        var service = client.GetServiceProxy<IEchoService>();
        client.Start();

        Console.WriteLine(service.Echo("Hello World!"));

        client.Shutdown();
    }
    host.Shutdown();
}

// Service Definition
public interface IEchoService {

    string Echo(string text);

}

// Service Implementation
public class EchoService : IEchoService {

    public string Echo(string text) => text;

}

Publish - Subscribe

var address = @"localhost";
var port = 5000;
using (var host = new PublisherService(address, port)) {
    var proxy = host.GetServiceProxy<ILogService>();
    host.Start();
    var service = new LogService();
    using (var client = new SubscriptionServiceHost(address, port)) {
        client.RegisterService(service);
        client.Start();

        service.Log("Hello World!");

        client.Shutdown();
    }
    host.Shutdown();
}

// Service Definition
public interface ILogService {

    void Log(string text);

}

// Service Implementation
public class LogService : ILogService {

    public void Log(string text) => Console.WriteLine(text);

}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages