Example #1
0
 public override void HandleStreamMessageCall(IStreamMessageBuilder replyWriter,
                                              bool isRedelivered,
                                              IBasicProperties requestProperties,
                                              object[] args)
 {
     Console.Out.WriteLine("ShutdownableServer received a {0} request.",
                           isRedelivered ? "redelivered" : "new");
     if ((double)args[0] == 0)
     {
         Console.Out.WriteLine("Shutting down immediately.");
         Close();
         replyWriter.WriteObject("Shut down immediately");
     }
     else
     {
         Timer t = new Timer((int)(((double)args[0]) * 1000));
         t.Elapsed += new ElapsedEventHandler(OnTimeout);
         t.Enabled  = true;
         replyWriter.WriteObject("Will shut down in " + args[0] + " seconds");
     }
 }
Example #2
0
        public override void HandleStreamMessageCall(IStreamMessageBuilder replyWriter,
                                                     bool isRedelivered,
                                                     IBasicProperties requestProperties,
                                                     object[] args)
        {
            Console.Out.WriteLine("AddServer received a {0} request.",
                                  isRedelivered ? "redelivered" : "new");
            double sum = 0;

            foreach (double v in args)
            {
                Console.Out.WriteLine("Adding {0} to {1}, giving {2}.", v, sum, sum + v);
                sum += v;
            }
            Console.Out.WriteLine("The reply is {0}.", sum);
            replyWriter.WriteObject(sum);
        }
 public override void HandleStreamMessageCall(IStreamMessageBuilder replyWriter,
                                              bool isRedelivered,
                                              IBasicProperties requestProperties,
                                              object[] args)
 {
     Console.Out.WriteLine("ShutdownableServer received a {0} request.",
                           isRedelivered ? "redelivered" : "new");
     if ((double) args[0] == 0) {
         Console.Out.WriteLine("Shutting down immediately.");
         Close();
         replyWriter.WriteObject("Shut down immediately");
     } else {
         Timer t = new Timer((int) (((double) args[0]) * 1000));
         t.Elapsed += new ElapsedEventHandler(OnTimeout);
         t.Enabled = true;
         replyWriter.WriteObject("Will shut down in " + args[0] + " seconds");
     }
 }
Example #4
0
 public override void HandleStreamMessageCall(IStreamMessageBuilder replyWriter,
                                              bool isRedelivered,
                                              IBasicProperties requestProperties,
                                              object[] args)
 {
     Console.Out.WriteLine("AddServer received a {0} request.",
                           isRedelivered ? "redelivered" : "new");
     double sum = 0;
     foreach (double v in args) {
         Console.Out.WriteLine("Adding {0} to {1}, giving {2}.", v, sum, sum + v);
         sum += v;
     }
     Console.Out.WriteLine("The reply is {0}.", sum);
     replyWriter.WriteObject(sum);
 }