本文整理汇总了C#中Connector.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# Connector.Publish方法的具体用法?C# Connector.Publish怎么用?C# Connector.Publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connector
的用法示例。
在下文中一共展示了Connector.Publish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: 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);
}