当前位置: 首页>>代码示例>>C#>>正文


C# Message.Set方法代码示例

本文整理汇总了C#中Message.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Set方法的具体用法?C# Message.Set怎么用?C# Message.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message.Set方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            if (args.Length != 2)
            {
                Console.WriteLine("Wrong number of arguments. Got {0} instead.", args.Length);
                return;
            }

            MyHandler myH = new MyHandler();
            Parameters p = new Parameters();
            p.ServerUrl = args[0];

            Connector c = new Connector();
            if (c.Open(p))
            {
                Message m = new Message();
                m.Set("do_method", "notify");
                m.Set("kn_to", args[1]);
                m.Set("kn_payload", "Hello");
                m.Set("nickname", "dotnet");
                m.Set("kn_response_format", "simple");

                c.Publish(m, myH);

                c.Close();
            }
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:30,代码来源:Class1.cs

示例2: testEmpty

        public void testEmpty()
        {
            TestUtil.INIT_TESTCASE("testEmpty");

            Message m1 = new Message();
            m1.Set("field1", "Value1");
            m1.Set("field2", "Value2");
            m1.Set("field3", "Value3");
            m1.Set("field4", "Value4");
            TestUtil.dumpMsg("Msg: m1", m1);

            m1.Empty();
            TestUtil.dumpMsg("Msg: m1", m1);
            Assertion.Assert("m1.IsEmpty()", m1.IsEmpty());
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:15,代码来源:messageTS.cs

示例3: testCopy

        public void testCopy()
        {
            TestUtil.INIT_TESTCASE("testCopy");

            Message m1 = new Message();
            m1.Set("field1", "Value1");
            m1.Set("field2", "Value2");
            m1.Set("field3", "Value3");
            m1.Set("field4", "Value4");
            TestUtil.dumpMsg("Msg: m1", m1);

            Message m2 = new Message();
            m2.Copy(m1);
            TestUtil.dumpMsg("Msg: m1", m1);
            TestUtil.dumpMsg("Msg: m2", m2);

            Assertion.Assert("m1.IsEqual(m2)", m1.IsEqual(m2));
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:18,代码来源:messageTS.cs

示例4: ProcessRSSItem

        void ProcessRSSItem(XmlNode n)
        {
            string srcTitle = n["title"].InnerText;
            string srcLink = n["link"].InnerText;
            string srcDesc = n["description"].InnerText;

            Console.WriteLine(srcLink);

            XmlDocument xd = new XmlDocument();
            try
            {
                xd.Load(srcLink);
                XmlNodeList nl = xd.SelectNodes("/rss/channel/item");
                if (nl.Count == 0)
                    return;

                string prefix = "  ";
                Console.WriteLine(prefix + "There are {0} items", nl.Count.ToString());

                Message m = new Message();

                for (int i = nl.Count - 1; i >= 0; i--)
                {
                    try
                    {
                        XmlNode item = nl[i];
                        string title = item["title"].InnerText;
                        string link = item["link"].InnerText;
                        string desc = item["description"].InnerText;
                        Console.WriteLine(prefix + i.ToString() + ":" + title);
                        Console.WriteLine(prefix + prefix + link);
                        Console.WriteLine(prefix + prefix + desc);

                        m.Set("do_method", "notify");
                        m.Set("kn_response_format", "simple");
                        m.Set("kn_to", "/headlines");
                        m.Set("kn_id", link);
                        m.Set("title", title);
                        m.Set("link", link);
                        m.Set("description", desc);
                        m_Connector.Publish(m, null);
                    }
                    catch (Exception ie)
                    {
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Failed to load " + srcTitle + " " + srcDesc);
            }
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:53,代码来源:RSSPub.cs

示例5: testPub

        public void testPub()
        {
            TestUtil.INIT_TESTCASE("testPub");
            TestUtil.resetCounters();

            Connector c1 = new Connector();
            Parameters p1 = new Parameters();
            TestUtil.PubRequestStatusHandler prsh = new TestUtil.PubRequestStatusHandler();
            bool b;

            p1.ServerUrl = TestUtil.getServer();
            b = c1.Open(p1);
            Assertion.Assert("b", b);
            Assertion.Assert("c1.IsConnected()", c1.IsConnected());

            Message m1 = new Message();
            m1.Set("do_method", "notify");
            m1.Set("kn_to", "/what/knchat/messages");
            m1.Set("nickname", "abc");
            m1.Set("kn_response_format", "simple");

            for(int i = 1; i <= 10; i++)
            {
                m1.Set("kn_payload", "Hello-" + i);
                b = c1.Publish(m1, prsh);
            }

            TestUtil.dumpCounters();
            //pubReqSH    OnSuccess    : 10 pub connections -----------------+
            //pubReqSH    OnError      : ---------------------------------+  |
            //pubConnSH   OnConnStatus : No conn status handler -------+  |  |
            //subReqSH    OnSuccess    : No sub --------------------+  |  |  |
            //subReqSH    OnError      : No sub -----------------+  |  |  |  |
            //subConnSH   OnConnStatus : No sub --------------+  |  |  |  |  |
            //subListener OnUpdate     : No sub -----------+  |  |  |  |  |  |
            string counterResult1 = TestUtil.checkCounters(0, 0, 0, 0, 0, 0, 10);
            Assertion.Assert(counterResult1, counterResult1 == TestUtil.TU_OK);
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:38,代码来源:connectTS.cs

示例6: testSerialization

        public void testSerialization()
        {
            TestUtil.INIT_TESTCASE("testSerialization");

            Message m1 = new Message();
            m1.Set("field1", "Value1");
            m1.Set("field2", "Value2  ");
            m1.Set("field3", "  Value3");
            m1.Set("field4", "  Value4  ");
            TestUtil.dumpMsg("Msg: m1", m1);

            string str1 = m1.GetAsSimpleFormat();
            TestUtil.dump("str1=" + str1);

            Message m2 = new Message();
            bool result = m2.InitFromSimple(str1);
            Assertion.Assert("result", result);
            TestUtil.dumpMsg("Msg: m2", m2);

            string val1 = "";
            string val2 = "";
            string val3 = "";
            string val4 = "";
            string val5 = "";
            result = m2.Get("field1", ref val1);
            Assertion.Assert("result", result);
            result = m2.Get("field2", ref val2);
            Assertion.Assert("result", result);
            result = m2.Get("field3", ref val3);
            Assertion.Assert("result", result);
            result = m2.Get("field4", ref val4);
            Assertion.Assert("result", result);
            result = m2.Get("field5", ref val5);
            Assertion.Assert("!result", !result);

            Assertion.Assert("val1 = Value1", val1 == "Value1");
            Assertion.Assert("val2 = Value2", val2 == "Value2  ");
            Assertion.Assert("val3 = Value3", val3 == "  Value3");
            Assertion.Assert("val4 = Value4", val4 == "  Value4  ");

            Assertion.Assert("m2.IsEqual(m1)", m2.IsEqual(m1));
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:42,代码来源:messageTS.cs

示例7: testGetEnumerator

        public void testGetEnumerator()
        {
            TestUtil.INIT_TESTCASE("testGetEnumerator");

            Message m1 = new Message();
            m1.Set("Field1", "Value1");
            m1.Set("Field2", "Value2");
            m1.Set("Field3", "Value3");
            m1.Set("Field4", "Value4");

            IEnumerator ienum = m1.GetEnumerator();

            MessageEntry msge;
            int count = 0;
            ArrayList fields = new ArrayList();
            ArrayList values = new ArrayList();
            while(ienum.MoveNext())
            {
                count++;
                msge = (MessageEntry)ienum.Current;
                TestUtil.dump("       " + msge.Field + ":" + msge.Value);
                fields.Add(msge.Field);
                values.Add(msge.Value);
            }

            Assertion.Assert("fields[0] == field1", (string)fields[0] == "Field1");
            Assertion.Assert("fields[1] == field2", (string)fields[1] == "Field2");
            Assertion.Assert("fields[2] == field3", (string)fields[2] == "Field3");
            Assertion.Assert("fields[3] == field4", (string)fields[3] == "Field4");
            Assertion.Assert("values[0] == value1", (string)values[0] == "Value1");
            Assertion.Assert("values[1] == value2", (string)values[1] == "Value2");
            Assertion.Assert("values[2] == value3", (string)values[2] == "Value3");
            Assertion.Assert("values[3] == value4", (string)values[3] == "Value4");
            Assertion.Assert("count = 4", count == 4);
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:35,代码来源:messageTS.cs

示例8: testGet

        public void testGet()
        {
            TestUtil.INIT_TESTCASE("testGet");

            Message m1 = new Message();
            m1.Set("field1", "Value1");
            m1.Set("field2", "Value2");
            m1.Set("field3", "Value3");
            m1.Set("field4", "Value4");
            TestUtil.dumpMsg("Msg: m1", m1);

            string str1 = "";
            bool result;
            result = m1.Get("field1", ref str1);
            TestUtil.dump("str1=" + str1);

            Assertion.Assert("result", result);
            Assertion.Assert("str1.Equals(\"Value1\")", str1.Equals("Value1"));
            Assertion.Assert("!str1.Equals(\"Value1\")", !str1.Equals("Value2"));

            result = m1.Get("field5", ref str1);
            Assertion.Assert("!result", !result);
        }
开发者ID:kragen,项目名称:mod_pubsub,代码行数:23,代码来源:messageTS.cs


注:本文中的Message.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。