Ejemplo n.º 1
0
        /// <summary>
        /// A Message receive callback delegate that prints the SDT content
        /// of received messages.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        public void PrintReceivedMessage(Object source, MessageEventArgs args)
        {
            IMessage      message   = args.Message;
            ISDTContainer container = SDTUtils.GetContainer(message);
            StringBuilder sb        = new StringBuilder();

            if (container is IMapContainer)
            {
                IMapContainer map = (IMapContainer)container;
                sb.Append("map={");
                while (map.HasNext())
                {
                    KeyValuePair <string, ISDTField> entry = map.GetNext();
                    sb.Append(string.Format("\n\tkey={0} value={1}", entry.Key, entry.Value.Value.ToString()));
                }
                sb.Append("}\n");
            }
            else if (container is IStreamContainer)
            {
                IStreamContainer stream = (IStreamContainer)container;
                sb.Append("stream={");
                while (stream.HasNext())
                {
                    ISDTField entry = stream.GetNext();
                    sb.Append(string.Format("\n\tvalue={0}", entry.Value.ToString()));
                }
                sb.Append("}\n");
            }
            SampleUtils.HandleMessageEvent(source, args);
            Console.WriteLine(sb.ToString());
        }
Ejemplo n.º 2
0
 public void HandleMessageEvent(Object source, MessageEventArgs args)
 {
     Console.WriteLine("Received message on " + _n);
     SampleUtils.HandleMessageEvent(source, args);
 }