Beispiel #1
0
        static void RunEchoServer()
        {
            var echoDescriptor = new ServiceDescriptor
            {
                Name        = "echo",
                Description = "demo service",
                ServiceHost = "localhost",
                ServicePort = 0, //the port can be set to any
            };
            var descManager = new ServiceDescriptor
            {
                Name        = "service_manager",
                Description = "global service manager",
                ServiceHost = "localhost",
                ServicePort = 3324,
                AccessToken = "AnyClient"
            };

            using var resolver = new TcpServiceResolver(descManager, clientID: "logger_client", secretKey: "02384Je5");
            var remoteLogger = resolver.GetService <ILogger>("logger");

            var echoService = new EchoImpl();

            using var echoRunner = new TcpServiceRunner <IEcho2>(
                      service: echoService,
                      descriptor: echoDescriptor,
                      logger: remoteLogger,
                      sslCertificate: null);
            echoRunner.Start(descManager, clientID: "echo_provider", secretKey: "F*ooE3");

            echoService.WaitForStop();
            Thread.Sleep(2000); //sleep a while so that the client can release the proxy first
        }
Beispiel #2
0
        static void RunServiceManager()
        {
            var logger      = BuilderLogger();
            var descManager = new ServiceDescriptor
            {
                Name        = "service_manager",
                Description = "global service_manager",
                ServiceHost = "localhost",
                ServicePort = 3324,  //service manager must specify a port
                AccessToken = "AnyClient"
            };

            using var managerRunner = TcpManagerRunner.Instance;
            managerRunner.Logger    = logger;
            var config = AccessConfig.FromJson(ManagerConfigJson);

            managerRunner.Config(config);
            managerRunner.Start(descManager, sslCertificate: null);

            var loggerDescriptor = new ServiceDescriptor
            {
                Name        = "logger",
                Description = "log service",
                ServiceHost = "localhost",
                ServicePort = 3325,
            };

            using var loggerRunner = new TcpServiceRunner <ILogger>(
                      service: logger,
                      descriptor: loggerDescriptor,
                      logger: logger,
                      sslCertificate: null);
            loggerRunner.Start(descManager, clientID: "logger_provider", secretKey: "Dx90et54");
            while (true)
            {
                Thread.Sleep(1000);
            }
        }