Example #1
0
        protected void SendMessage(object sender, EventArgs e)
        {
            //Make the RPC request
            CalculateRequest request = new CalculateRequest() { Terms = Convert.ToInt32(MessageText.Text) };
            CalculateResponse response = EasyNetQBus.Current().SynchronousResponse<CalculateRequest, CalculateResponse>(request);
            string messageText = string.Format("Pi is not: {0}", response.Pi.ToString());

            //Publish a broadcast message
            BroadcastMessageRequest broadcast = new BroadcastMessageRequest() { MessageText = messageText };
            EasyNetQBus.Current().Publish<BroadcastMessageRequest>(broadcast);

            //Get the list of broadcast messages (RPC again)
            GetMessagesRequest messagesRequest = new GetMessagesRequest();
            GetMessagesResponse messagesResponse = EasyNetQBus.Current().SynchronousResponse<GetMessagesRequest, GetMessagesResponse>(messagesRequest);

            //Print out the last result. Bear in mind we're async - this may not be your last request!
            MessageList.DataSource = messagesResponse.Messages;
            MessageList.DataBind();
        }
 public static CalculateResponse Consume(CalculateRequest request)
 {
     CalculateResponse response = new CalculateResponse();
     response.Pi = CalculateGregoryApproximation(request.Terms);
     return response;
 }
 public void should_generate_response()
 {
     CalculateRequest request = new CalculateRequest() { Terms = 10 };
     CalculateResponse response = CalculateConsumer.Consume(request);
     Assert.AreEqual(3.05865035384706, response.Pi, 0.000001);
 }
Example #4
0
 public static void Consume(CalculateRequest inbound)
 {
     Console.WriteLine(string.Format("Just saw request for pi to {0} decimals", inbound.Terms));
 }