Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (!parser.ParseArguments(args, options))
                Environment.Exit(1);

            using (var context = ZmqContext.Create())
            {
                using (var socket = context.CreateSocket(SocketType.REP))
                {
                    foreach (var bindEndPoint in options.bindEndPoints)
                        socket.Bind(bindEndPoint);
                    while (true)
                    {
                        Thread.Sleep(options.delay);
                        var rcvdMsg = socket.Receive(Encoding.UTF8);
                        Console.WriteLine("Received: " + rcvdMsg);
                        var replyMsg = options.replyMessage.Replace("#msg#", rcvdMsg);
                        Console.WriteLine("Sending : " + replyMsg + Environment.NewLine);
                        socket.Send(replyMsg, Encoding.UTF8);
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] arg)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            //if (!parser.ParseArguments(args, options))
            //    Environment.Exit(1);

            //commandAssembly = Assembly.LoadFile(Environment.CurrentDirectory+ "\\CommonFunctions.dll");

            string commandArgs = null;

            HostFactory.Run(x =>                                 //1
            {
                x.AddCommandLineDefinition("arguments", f => { commandArgs = f; });
                x.ApplyCommandLine();

                Console.WriteLine(commandArgs);

                string[] args = commandArgs.Split(' ');

                parser.ParseArguments(args, options);
                x.Service<BowService>(s =>                        //2
                {
                    s.ConstructUsing(name => new BowService());     //3
                    s.WhenStarted(tc => tc.Start(options));              //4
                    s.WhenStopped(tc => tc.Stop());               //5
                });
                x.RunAsLocalSystem();                            //6

                x.SetDescription("Sample Bow Service Host");        //7
                x.SetDisplayName("BowService");                       //8
                x.SetServiceName("BowService");                       //9
            });                                                  //10
        }
Exemplo n.º 3
0
        public void RunInZeroMqMode(Options options)
        {
            using (var context = ZmqContext.Create())
            {
                using (var socket = context.CreateSocket(SocketType.REP))
                {
                    foreach (var bindEndPoint in options.bindEndPoints)
                        socket.Bind(bindEndPoint);
                    while (keepRunning)
                    {
                        Thread.Sleep(options.delay);
                        var rcvdMsg = socket.Receive(Encoding.UTF8);
                        Console.WriteLine("Received: " + rcvdMsg);

                        string returnValue = CommandProcessor(rcvdMsg);

                        socket.Send(returnValue, Encoding.UTF8);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void Start(Options options) { _requestProcessor.RunInZeroMqMode(options); }
Exemplo n.º 5
0
        //        private static Assembly commandAssembly = null;
        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (!parser.ParseArguments(args, options))
                Environment.Exit(1);

            //commandAssembly = Assembly.LoadFile(Environment.CurrentDirectory+ "\\CommonFunctions.dll");

            RunInZeroMqMode(options);

            //RunInConsoleMode();
        }