示例#1
0
        // In WriteCLient tab, XML Message stream containing all queries is sent to its target address upon the click of this button
        private void WCSendList_Click(object sender, RoutedEventArgs e)
        {
            MessageXML.Save("MessageStream.xml");
            MessageGenerator maker           = new MessageGenerator();
            Message          WCMessageStream = maker.MessageCreator(UtilityMethods.makeUrl(LocalAddress, LocalPort), UtilityMethods.makeUrl(RemoteAddress, RemotePort));

            WCMessageStream.MessageContent = MessageXML.ToString();
            WCMessageStream.MessageID      = String.Concat("WC", WCMessageID.ToString());
            StatusLabel1.Content           = "Sending to " + WCMessageStream.ToURL;
            try
            {
                WCMessageStream.TimeSent = DateTime.Now;
                if (UISender.sendMessage(WCMessageStream))  // The stream is sent across at this line.
                {
                    StatusLabel1.Content = "Message stream sent";
                }
                else
                {
                    StatusLabel1.Content = "Failed to send";
                }
            }
            catch (Exception EX)
            {
                StatusLabel1.Content = EX.Message;
            }
            MessageXML.Save("MessageStream.xml");
            MessageXML.Element("MessageStream").Elements().Remove();
            WCMessages.Items.Clear();
        }
示例#2
0
 // It is the event associated with Send button under LaunchTesters tab. It sends messages to the port mentioned in textbox upon the connection. WPF then considers that port as remote port.
 private void Sender(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!RemotePort.Equals(rPort.Text))
         {
             RemotePort = rPort.Text;
         }
         MessageGenerator maker = new MessageGenerator();
         Message          msg   = maker.MessageCreator(UtilityMethods.makeUrl(LocalAddress, LocalPort), UtilityMethods.makeUrl(RemoteAddress, RemotePort));
         lStat.Text         = "Sending to" + msg.ToURL;
         UISender.LocalURL  = msg.FromURL;
         UISender.RemoteURL = msg.ToURL;
         msg.TimeSent       = DateTime.Now;
         TimeSent           = DateTime.Now;
         lStat.Text         = "Attempting to connect";
         if (UISender.sendMessage(msg))
         {
             lStat.Text = "Connected";
         }
         else
         {
             lStat.Text = "Connection failed";
         }
         postSndMsg(msg.MessageContent);
     }
     catch (Exception ex)
     {
         lStat.Text = ex.Message;
     }
 }
示例#3
0
        private void RCSendList_Click(object sender, RoutedEventArgs e)             // In ReadCLient tab, XML Message stream containing all queries is sent to its target address upn the click
        {                                                                           // of this button. Message ID is generated based on value of RCMessageID value declared at the start.
            MessageGenerator maker           = new MessageGenerator();
            Message          RCMessageStream = maker.MessageCreator(UtilityMethods.makeUrl(LocalAddress, LocalPort), UtilityMethods.makeUrl(RemoteAddress, RemotePort));

            RCMessageStream.MessageContent = MessageXML.ToString();
            RCMessageStream.MessageID      = String.Concat("RC", RCMessageID.ToString());
            StatusLabel.Content            = "Sending to " + RCMessageStream.ToURL;
            try
            {
                RCMessageStream.TimeSent = DateTime.Now;
                if (UISender.sendMessage(RCMessageStream))       // Cuurent date time is stored when a message is sent
                {
                    StatusLabel.Content = "Message stream sent";
                }
                else
                {
                    StatusLabel.Content = "Failed to send";
                }
            }
            catch (Exception EX)
            {
                StatusLabel.Content = EX.Message;
            }
            MessageXML.Save("MessageStream.xml");                          // XML Message is saved before it is sent across
            MessageXML.Element("MessageStream").Elements().Remove();       // Elements are removed as to make the same XML document for the query results received after processing.
            RCMessages.Items.Clear();                                      // Those would be added in the same XML message to avoid losing any property required to measure the performance
        }
        static void Main(string[] args)
        {
            MessageGenerator mm      = new MessageGenerator();
            Message          message = mm.MessageCreator("fromFoo", "toBar");

            UtilityMethods.showMessage(message);
            Console.Write("\n\n");
        }